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;

    // panelpopup.Visible = true;
    lblMsgPop.Visible = false;
    rbtnCivil.Visible = false;
    rbtnSR.Visible = true;
    // pnlScheduelItems.Visible = true;
    gvDetail.Visible = true;
    btnMeasurement.Visible = false;
    btnMeasurement.Enabled = true;


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

    if (!Page.IsPostBack)
    if (Session["USERID"] != null)
    pnlVisible.Visible = false;
    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;
    //lbtnSRBook_Click(null, null);
    //lbtnSRBook.PostBackUrl = Request.RawUrl;

  • #767786
    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 :

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

  • #767803

    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.

    Blog :

  • Sign In to post your comments