LinkButton PostBackUrl

J

Jon

Hello all,

I have a LinkButton with the PostBackUrl set, I also have an OnClick
event set.

For some reason, the OnClick event is only hit the second time I click
the LinkButton. If I remove the PostBackUrl attribute it hits it every
time. Why is that?

Thanks,

Jon
 
G

Guest

Hi Jon,

I believe postbackURL lets the button post to a different page. I am
assuming you want to redirect the user in some way? Instead, set the button's
commandargument property to the URL you want, and then at the end of the
OnClick event, redirect the user to the value of the CommandArgument Property.

You can refer to the code below for this:

protected void LinkButton1_clk(object sender, EventArgs e)
{
if (someVariable == 2)
{
Response.Redirect(LinkButton1.CommandArgument.ToString());
}
}

Hope this helps.

Regards,
Manish
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top