Click here to Skip to main content
14,832,124 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
on button click i want to bind data with html from code behind cs file.
Posted
Updated 21-Feb-14 5:57am
v2
Comments
ZurdoDev 21-Feb-14 10:57am
   
Where are you stuck?
utm 22-Feb-14 2:16am
   
htmlStr = htmlStr + "<tr>";
for (cellCtr = 0; cellCtr <= cellCnt; cellCtr++)
{
htmlStr += "<td>" + cellvalue + "</td>";
cellvalue = cellvalue + 1;
}
htmlStr = htmlStr + "</tr>";

i have bind the html according to my need now i want to display this html in aspx page on button click event . i have try <%htmlstr%> in aspx page but it not working. plz help.
utm 22-Feb-14 15:26pm
   
sorry.. for late reply :(
ZurdoDev 22-Feb-14 16:22pm
   
Again, where though are you stuck? In a button click event? Just double-click your button and that will create the click event for you.
utm 23-Feb-14 1:23am
   
i can create htmlstr on button click but

how can i pass my htmlstr at runtime to the .aspx page on button click

protected void Btn_gen_Click(object sender, EventArgs e)
{
???? how ?

}
ZurdoDev 23-Feb-14 8:08am
   
This still does not make any sense. You have an aspx page because that is where your button is. Id you want add a label and set its text to the html you want.
utm 23-Feb-14 16:12pm
   
thanks for reply.
its working ..
protected void Btn_gen_Click(object sender, EventArgs e)
{
Label1.Text = htmlStr;
}

for that i have add lable control in my aspx page. and set html in label.text. its work no problem.

but is there any way to attach my htmlstr variable directly to the aspx page without using any type of server side control. i am asking it because i don't want add controls in my page its makes the page slow.




ZurdoDev 23-Feb-14 16:59pm
   
There's actually a good chance that you trying to do everything on your own instead of taking advantage of .Net controls is going to slow things down.

You can use Response.Write(string) but then you don't have as much control as to where it ends up on your page, hence the reason to use a label.

You can add a label to your page and then set the Text property to the html you are generating.

However, it appears like you are trying to do a lot of work that comes built in to .Net so perhaps .Net is not the right language or perhaps you need to learn how to use .Net controls.
   

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