Showing posts with label html. Show all posts
Showing posts with label html. Show all posts

Wednesday, March 7, 2012

How to add a variable in Source view ?

There are 3 views in VS IDE, Designer, Code and Source.

In source view, there are html codes, how do I add a variable into it ?

For example:

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:JJConnectionString %>"
SelectCommand="SELECT * FROM [Tbl]"

...

How to change the SelectCommand to like:

SelectCommand="SELECT * FROM [Tbl] WHERE [CREATEDBY] = '" & User.Identity.Name & "'"

The User.Identity.Name is not valid in source view, but i need it to work, are there any way ?

Hello my friend,

To use code within aspx/ascx files, you enclose it within <% %> tags. The page directive at the top of your aspx pages is an example of this.

<%@. %> is for directives

<%= %> is for simple printing of code/variables. Try this on your web page: -

<%

=User.Identity.Name %>

<%# %> is for pre-processing but usually used in binding controls to print/use fields of the data source: -

<asp:Repeater ID="rptCountries" runat="server" Visible="true">
<ItemTemplate>
<td width="200"><%# Container.DataItem("CountryName")%><br/>
</ItemTemplate>
</asp:Repeater>

Kind regards

Scotty

Friday, February 24, 2012

How to add a field containing HTML to be properly rendered

I have a database notes field, which contains the text with some html
elements (fonts, styles, etc). If I add it to the report all html tags come
in plain text. Is there a way to render the field text as html? If not is
there a simple way to strip off all html tags?There is not a way to show as html. To strip off the html I believe there is
a framework function that you could use. Set the value of the textbox to an
expression like this:
= Code.StripHTML(Fields!Fieldname.value)
You would write the function StripHTML that would return the value with the
html striped.
This link shows how to do this using regular expressions.
http://weblogs.asp.net/rosherove/archive/2003/05/13/6963.aspx
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Alex Ch" <Alex Ch@.discussions.microsoft.com> wrote in message
news:ADDDE0F6-2DD0-49EC-875B-99694EB61BC0@.microsoft.com...
>I have a database notes field, which contains the text with some html
> elements (fonts, styles, etc). If I add it to the report all html tags
> come
> in plain text. Is there a way to render the field text as html? If not is
> there a simple way to strip off all html tags?