c# - Showing and closing a usercontrol using javascript -


i have asp.net application did not write trying modify.

it contains aspx page contains data grid , usercontrol. page starts life items in datagrid, , allows user chose item edit, user can click on edit button causes usercontrol open in modal fashion using javascript.

on user control, user can edit details , can finish clicking on close button or save button.

at point usercontrol stays on page - want disappear , show me page behind - i.e. page datagrid of items.

also, 1 of items has changed, want refresh grid.

the html code have in main file (mytest.aspx) like:

: : <%@ register tagprefix="uc" tagname="mymodal"  src="~/usercontrols/mymodal.ascx" %> : : <script language="javascript" type="text/javascript">     function openusermodal() {         $("#mdlmycontrol").modal({ 'show': true, 'backdrop': "static", 'keyboard': false });     } </script> : : <asp:button id="btnedit" runat="server" text="edit" onclick="btnedit_click" enabled="true" /> : : <div class="modal fade" id="mdlmycontrol" tabindex="-1" role="dialog" aria-labelledby="mymodallabel" aria-hidden="true">     <div class="modal-dialog">         <asp:updatepanel id="updmymodal"  runat="server" updatemode="conditional" childrenastriggers="true">             <contenttemplate>                 <uc:mymodal id="ucmymodal" runat="server"></uc:modal>             </contenttemplate>         </asp:updatepanel>     </div> </div> 

and code behind file (mytest.aspx.cs) has:

protected void page_load(object sender, eventargs e) {     ucmymodal.mymodal_updated += new eventhandler(mymodal_updated);     ucmymodal.mymodal_closed += new eventhandler(mymodal_closed); : : }  protected void btnedit_click(object sender, eventargs e) {     ucmymodal.databind();      scriptmanager.registerstartupscript(this.updmymodal, this.updmymodal.gettype(), "pop", "openusermodal();", true); }  private void userdetailsnew_updated(object sender, eventargs e) {     databind();     //response.redirect(request.url.absoluteuri); }  private void userdetailsnew_closed(object sender, eventargs e) {     databind();     //response.redirect(request.url.absoluteuri); } 

the html code mymodal.ascx has:

<asp:updatepanel id="upddetails" runat="server">     <contenttemplate>          <div class="modal-content" style="width: 970px; margin-left: -195px;">              :             :             <asp:button id="btnclose" class="btn btn-default" runat="server" text="close" onclick="btnclose_click" />             <asp:button id="btnsave" class="btn btn-custom" runat="server" text="save" onclick="btnsave_click" />         </div>      </contenttemplate> </asp:updatepanel> 

and code behind file control mymodal.ascx.cs has:

protected void btnsave_click(object sender, eventargs e) {     :     :     onmymodal_update(); }  protected void btnclose_click(object sender, eventargs e) {     onmymodal_close(); }   public event eventhandler mymodal_updated;  public void onmymodal_update() {     if (mymodal_updated != null)     {         mymodal_updated(this, eventargs.empty);     } }  public event eventhandler mymodal_closed;  public void onmymodal_close() {     if (mymodal_closed != null)     {         mymodal_closed(this, eventargs.empty);     } } 

i realise not invoking $.modal.hide method hide usercontrol not know should put or how invoke it.

hope bit more aspx/javascript knowledge can me sort out.

thanks in advance.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -