RegisterOnSubmitStatement after client-side validation

后端 未结 2 1579
闹比i
闹比i 2021-02-19 07:24

I need to insert a bit of Javascript into the process when a Web Form is submitted, but after the client side validation takes place.

RegisterOnSubmitStatement seems to

2条回答
  •  情书的邮戳
    2021-02-19 08:14

    that´s right, the RegisterOnSubmitStatement DO NOT WORK in the init function. It should be called after in the page lige cycle. I thing the right place therefor is:

    "PreRenderComplete"

    protected override OnInit(EventArgs e) 
    { 
       Page.PreRenderComplete+= new EventHandler(Page_PreRenderComplete); 
       base.OnInit(e); 
    } 
    
    void Page_PreRenderComplete(object sender, EventArgs e) 
    { 
       Page.ClientScript.RegisterOnSubmitStatement(typeof(Page), "name", "JS code here"); 
    }
    

提交回复
热议问题