Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 25, 2012 07:10 AM by XIII
Member
15 Points
70 Posts
Dec 24, 2012 07:34 PM|LINK
Hi
How can I do it without running the javascript?
Response.Write("<script>alert('Hi')</script>");
I want to write "<script>alert('Hi')</script>" in the webform Thanks
All-Star
43038 Points
7031 Posts
MVP
Dec 25, 2012 05:39 AM|LINK
Hello,
You can include a asp:Label in your aspx page and set the text to the Label from code behind.
In your ASPX
<asp:Label runat="server" id="test></asp:Label>
In code behind (C#)
test.Text = "<script>alert('Hi')</script>";
Please 'Mark as Answer' if this post helps you.
Dec 25, 2012 05:52 AM|LINK
Ruchira Hello, You can include a asp:Label in your aspx page and set the text to the Label from code behind. In your ASPX <asp:Label runat="server" id="test></asp:Label> In code behind (C#) test.Text = "<script>alert('Hi')</script>";
It is not gonna work! a java script message comes up!
160 Points
113 Posts
Dec 25, 2012 06:09 AM|LINK
hey,
try this below,
<%= resultstr %>
in code Behind :
resultstr = <script>alert('Hi')</script>;
Dec 25, 2012 06:32 AM|LINK
AL MUBARAK hey, try this below, <%= resultstr %> in code Behind : resultstr = <script>alert('Hi')</script>;
Are you sure? It does not make sense! It did not work either!
182702 Points
23463 Posts
ASPInsiders
Moderator
Dec 25, 2012 07:10 AM|LINK
Hi,
make use of a Literal control in your webform. In the code behind write it like this:
ltJavascript.Text = Server.HtmlEncode("<script>alert('Hi')</script>" );
Grz, Kris.
newcoder61
Member
15 Points
70 Posts
writing javascript command in the webform
Dec 24, 2012 07:34 PM|LINK
Hi
How can I do it without running the javascript?
Response.Write("<script>alert('Hi')</script>");
I want to write "<script>alert('Hi')</script>" in the webform
Thanks
Ruchira
All-Star
43038 Points
7031 Posts
MVP
Re: writing javascript command in the webform
Dec 25, 2012 05:39 AM|LINK
Hello,
You can include a asp:Label in your aspx page and set the text to the Label from code behind.
In your ASPX
In code behind (C#)
test.Text = "<script>alert('Hi')</script>";
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.newcoder61
Member
15 Points
70 Posts
Re: writing javascript command in the webform
Dec 25, 2012 05:52 AM|LINK
It is not gonna work! a java script message comes up!
AL MUBARAK
Member
160 Points
113 Posts
Re: writing javascript command in the webform
Dec 25, 2012 06:09 AM|LINK
hey,
try this below,
<%= resultstr %>
in code Behind :
resultstr = <script>alert('Hi')</script>;
Al Mubarak
newcoder61
Member
15 Points
70 Posts
Re: writing javascript command in the webform
Dec 25, 2012 06:32 AM|LINK
Are you sure? It does not make sense! It did not work either!
XIII
All-Star
182702 Points
23463 Posts
ASPInsiders
Moderator
MVP
Re: writing javascript command in the webform
Dec 25, 2012 07:10 AM|LINK
Hi,
make use of a Literal control in your webform. In the code behind write it like this:
ltJavascript.Text = Server.HtmlEncode("<script>alert('Hi')</script>" );Grz, Kris.
Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!