Invalid postback or callback argument. Event validation is enabled using ''

后端 未结 30 1868
生来不讨喜
生来不讨喜 2020-11-22 05:08

I am getting the following error when I post back a page from the client-side. I have JavaScript code that modifies an asp:ListBox on the client side.

How do we fix

30条回答
  •  北荒
    北荒 (楼主)
    2020-11-22 05:14

    What worked for me is moving the following code from page_load to page_prerender:

    lstMain.DataBind();
    Image img = (Image)lstMain.Items[0].FindControl("imgMain");
    
    // Define the name and type of the client scripts on the page.
    String csname1 = "PopupScript";
    Type cstype = this.GetType();
    
    // Get a ClientScriptManager reference from the Page class.
    ClientScriptManager cs = Page.ClientScript;
    
    // Check to see if the startup script is already registered.
    if (!cs.IsStartupScriptRegistered(cstype, csname1))
    {
        cs.RegisterStartupScript(cstype, csname1, "");
    }
    

提交回复
热议问题