0

I need to show/hide a reusable modal popup that it is in a UserControlWeb (ascx).

In my ASPX web, I defined the UC:

<%@ Register TagPrefix="uc" TagName="uc1" Src="~/Controls/modalpopup.ascx" %>
<uc:uc1 ID="ModalPopup1" runat="server" />

I can show/hide the modalpopup with javascript:

$find('MBehavior').show();
$find('MBehavior').hide();

But, I need to do from behind code of my ASPX web.

It is posible?

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
user2481894
  • 11
  • 1
  • 6

3 Answers3

0

Try the above

 string script = @"  <script type=""text/javascript""> 
                  $find('MBehavior').show();
                });</script>";
            ClientScript.RegisterStartupScript(Page.GetType(), "", script);
kostas ch.
  • 1,960
  • 1
  • 17
  • 30
0

Maybe if you have updatepanel in your page you can try;

ScriptManager.RegisterStartupScript(updatePanelID, updatePanelID.GetType(), Guid.NewGuid().ToString(), "$find('MBehavior').show(); $find('MBehavior').hide();", true);
CocLn
  • 742
  • 10
  • 15
0

if you want to to run from aspx:

$("#mybutton").click(function(e) {
      $find('MBehavior').show();
      $find('MBehavior').hide();
      e.preventDefault();
    });

if from code behind:

$("#mybutton").click(function(e) {
$.ajax( {
type:'Get',
url:'aspxfilename/mymethod',
success:function(data) {

}

});
e.preventDefault();
});

and in .cs file create a method:

[WebMethod]
public static string mymethod()
{
//run javascript
}
Zaki
  • 5,540
  • 7
  • 54
  • 91