What does webform_DoPostBackWithOptions() do?

后端 未结 4 1476
無奈伤痛
無奈伤痛 2021-02-01 19:45

I have a button declared like this:



        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-01 19:57

    If you set the PostBackUrl property for the Button server control, then it means it is cross page posting and then asp.net framework instead of normal __DoPostBack() adds "WebForm_DoPostBackWithOptions". Check if you have "PostBackUrl" Property set for this button.

    
    
    

    If in your case you have not set the "PostBackUrl", then ASP.NET framework also does not add this by default for Button Control, so this means there has to be another control setting the OnClick attribute value probably using following sever side code -

        PostBackOptions myPostBackOptions = new PostBackOptions(this);
        myPostBackOptions.ActionUrl = "Page2.aspx";
        myPostBackOptions.AutoPostBack = false;
        myPostBackOptions.RequiresJavaScriptProtocol = true;
        myPostBackOptions.PerformValidation = true;
    
        // Add the client-side script to the HyperLink1 control.
        Button1.OnClientClick = Page.ClientScript.GetPostBackEventReference(myPostBackOptions);
    

提交回复
热议问题