You must Sign In to post a response.
  • Category: ASP.NET

    Linkbutton onclick event not firing, but working when commented the code in page load

    here is my Link Button(when i commented the pageload addnew item is working****)
    ************************

    <pre> <asp:LinkButton ID="lbtnSRBook" runat="server" OnClick="lbtnSRBook_Click" CausesValidation="False" Style="font-weight: 700"
    Text="Add Item" ></asp:LinkButton> </pre>


    code behind
    ***********
    <pre lang="C#">protected void lbtnSRBook_Click(object sender, EventArgs e)
    {



    if (Session["DemNumber"] != null)

    txtDemNumber.Text = Session["DemNumber"].ToString();

    //lbtnViewItems.Visible = true;lbtnSRBook_Click
    //lbtnSRBook.PostBackUrl = Request.Url.AbsoluteUri;
    pnlgridpop.Visible = false;
    Label4.Visible = false;
    ddChap.Visible = false;

    mpeSRBook.Show();
    // panelpopup.Visible = true;
    lblMsgPop.Visible = false;
    rbtnCivil.Visible = false;
    rbtnSR.Visible = true;
    // pnlScheduelItems.Visible = true;
    gvDetail.Visible = true;
    //mpeSRBook.Show();
    btnMeasurement.Visible = false;
    btnMeasurement.Enabled = true;
    }</pre>


    pageLoad
    *************

    <pre lang="C#">protected void Page_Load(object sender, EventArgs e)
    {


    if (!Page.IsPostBack)
    {
    if (Session["USERID"] != null)
    {
    pnlVisible.Visible = false;
    LoadEstimateDetails();
    pnlMis.Visible = true;
    lbtnSRBook.Visible = false;
    pnlgv.Visible = true;
    btnUpdate.Visible = true;
    btnMeasurement.Visible = true;
    btnSelected.Visible = false;
    pnlMeasurement.Visible = true;
    pnlgv.Visible = false;
    lblH1.Visible = false;
    //LoadEstimateDetails();
    //lbtnSRBook_Click(null, null);
    //lbtnSRBook.PostBackUrl = Request.RawUrl;


    }
    else
    {
    Response.Redirect("~//Login.aspx");
    }
    }
    }</pre>
  • #767786
    Hi
    set your code AutoPostBack=true then only we can post server side try this code



    <asp:LinkButton ID="lbtnSRBook" runat="server" OnClick="lbtnSRBook_Click" CausesValidation="False" Style="font-weight: 700" AutoPostBack="true"
    Text="Add Item" ></asp:LinkButton>


    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #767803
    Hi,

    Why are you using the below piece of code


    lbtnSRBook_Click(null, null);


    using this you are stopping the click event, after hiding this piece of code you can able to perform click event.

    Don't use the above line then it will work fine.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


Sign In to post your comments