<asp:LinkButton ID="lbDownloadFile" name = "lbDownloadFile" runat="server" CausesValidation="false"
onclick="lbDownloadFile_Click" />
I have this link button. on click:
protected void lbDownloadFile_Click(object sender, EventArgs e)
{ //here is my debug pointer/breakpoint
.........................
}
but this event is not firing. my Page_Load() event is firing. How to solve this problem?
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
if (Session[Antrage_AnfrageSessionNames.AgntNr] == null)
{
Response.Redirect("../UserSessionError.aspx");
}
try
{
if (Request.QueryString["Kundennummer"].ToString() != null)
{
//If kundennummer exists in QueryString then stores it to further use
kundennummer = Request.QueryString["Kundennummer"].ToString();
}
}
catch
{
kundennummer = string.Empty;
}
}
}
EDIT:
I am adding the code, what FireFox firebug shows me respective to the LinkButton.
I think the auto generated href is the main problem here.
I have created demo project and copy same code as you have written.It is working fine
in code behind file
I have just added text on link button.
Just go to button properties and set
@belogix comment is Good
I think Your Page load method have did anything wrong. May be your link button was reload from page load event.
Sample Error
If you using grid view and also this link button in inside of your grid, You are doing this things
Write Grid bind method
then you called the grid bind method in page load event
Your code look like now
Now, the grid reload on every post back .
Solution
Now you must need to set
!IsPostBack
and then call the grid bind method in inside of!IsPostBack
The code look like
This is your problem. and Also it's my guess.
Edit
Your code is working to me if i don't write any code on page-load event
See
Default.aspx
and server side code is
this is fine for me, So you missed anything in page load event
*
OnClientClick
andonclick
have not any problems. The problems created on pageload event,Please post your
pageload
code, otherwise we can't solve it. :)Edit 2
Please check the link button was OUTSIDE of your form elements. This link button should be inside of the form element
And your page load event should be
protected void Page_Load(**object sender, EventArgs e**) { //Code }
Not
You have missed