LinkButton Attributes.Add Onclick Response.Redirect

Posted by Anu_dgr8 under C# on 8/12/2010 | Views : 23185 | Status : [Member] | Replies : 1
hey guys!

at the itemcreated event of listview,i am finding the linkbutton like this:
LinkButton lnkbutton = (LinkButton)e.Item.FindControl("lnkMessage");

and then i want to add attribute to this linkbutton and i am doin it like this:

lnkbutton.Attributes.Add("OnClick", "Response.Redirect(~/Test/download.aspx?id="+ dt.Rows[i]["id"]");");

but some syntax error is coming...can somebody help me out?

thanks in advance

Thanks and Regards,
Hoosha Boosha


Posted by: Shankul2784 on: 8/12/2010 [Member] Bronze



This is wrong statement.

Response.Redirect is a server side concept.

In attributes you can add the javascript window.location.href

lnkbutton.Attributes.Add("OnClick", "window.location.href='~/Test/download.aspx?id="+ dt.Rows["id"]+"'");

i hope, this will help you.

Thanks & Regards,


Anu_dgr8, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response