vim
vim

Reputation: 874

Prevent the closing of modal popup(bootstrap) window on postback of ASP.Net button click

I have modal popup in asp.net page which get some values from db on submit button click and show that db value on same modal popup. But issue is that once i click the asp.net button then it fetch the value but modal where i need to show the db value it already close because of postback. So i need that on button click first server side side run ,retrieve db val and then run client side script to display this value in already opened modal. Please help me to resolve this problem

My client side code is on button click.

    $("#btnSubmit").click(function () {

        $('#PreviewModal').hide();
        $('#SubmitModal').ready();
        $('#SubmitModal').show();

    });

and server side script is

protected void btnSubmit_click(object sender, EventArgs e)
{
    Tsn objTsn = new Tsn();
    string Result=objTsn.OrderRecieptSeq("D");
    lblRef.InnerText = Result;
    btnSubmit.Attributes.Add("onClick", "clntclick();");


}

Upvotes: 1

Views: 855

Answers (1)

coder_b
coder_b

Reputation: 1025

I don't think this process would work, you may need to consider using register start-up script option to show your popups/modal

ClientScriptManager.RegisterClientScriptBlock

protected void Button1_Click(object sender, EventArgs e)
{        
    string script = "window.onload = function() { showpopup() };";
    ClientScript.RegisterStartupScript(this.GetType(), "showpopup", script, true);

}

Upvotes: 1

Related Questions