Click here to Skip to main content
15,890,897 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
string resp = "abcd";
i want to view the value of resp to our web page.
i want to write code to html source code in our .aspx page.
What is the code to view this.
Please help me
Posted

ans is

Response.Write(resp);
 
Share this answer
 
Comments
rahul dev123 18-May-11 7:31am    
if we write direct in source code(Html code)in .aspx page then its not working
If you want to add stirng value as a content of any HTML element, do following.

add HTML element to aspx with runat="server", example:

<div id="myDiv" runat="server" />


Add follwoing lines to code-behind:

string resp = "abcd";
myDiv.innerHtml = resp;
 
Share this answer
 
Here is another way


XML
<asp:Label runat="server" ID="lblDemo" Text="<%# resp %>"></asp:Label>



and dont forget to make the varible public
 
Share this answer
 
asp.net does not providing any method to popup value like MessageBox class providing in Windows Form...
but here another way to run javascript on serverside with alert() function of javascript.
MIDL
string msg = "<script>alert('your message');</script>";
//or you can give a message like this...
string msg = "<script>alert('The value of resp is : " + resp + "');</script>";

ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), msg, false);

Thanks & Regards,
Punit Parmar
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900