[RESOLVED] LinkButton does not perform assigned code
Hi!
I have LinkButton object, which I need to load another page after been pressed. At the same time, there is a code assigned to it. Let's say, assigning a value to a variable.
The funny thing is that when there is no URL yet assigned in Properties (PostBackUrl), then code is working fine. But as soon as I put there some link, button only work for this link, no code processed!
Any ideas on this tricky one? How to force it to simultaneously assign value to a variable and then move to another page?
Re: LinkButton does not perform assigned code
You should post your ASP.NET questions in the ASP.NET forum.
The PostBackUrl is the page you want to post your data back to when the link is clicked. It sounds to me like you don't want to post back to a different page. You probably want to post back to the same page, so don't set the PostBackUrl. If you want the Click event of the LinkButton to be handled in the same page then you certainly do want to post back to the same page. You can then redirect to a new page from that event handler.
Re: LinkButton does not perform assigned code
In the LinkButton's click event handler, do your processing, then Response.Redirect.
Re: LinkButton does not perform assigned code
Great! No need to use this LinkButton!
Thanx!
Re: [RESOLVED] LinkButton does not perform assigned code
The point of a LinkButton is to look like a HyperLink and behave like a Button. If that's what you want then a LinkButton is exactly what you should use, otherwise not.