Search code examples
c#javascriptasp.netsimplemodal

asp.net simplemodal usage


I need to display an iframe either on a button click or on an event (from an updatepanel) and using the code below I should be able to do just that.

I'm just not sure how to call the JS

var src = "http://sample.com/";
$.modal('<iframe src="' + src + '" height="450" width="830" style="border:0">', {
 closeHTML: "",
 containerCss: {
  backgroundColor: "#fff",
  borderColor: "#fff",
  height: 450,
  padding: 0,
  width: 830
 },
 overlayClose: true
});

If I just have it in a <script> it will just display on its own. I've had a look at the example on the main site but still unsure.

What is the syntax to call that from an event or by clicking a button/link?


Solution

  • Hope this helps, here i used a normal link. if you are using a .net button then use the

    Button.Attributes.Add("onclick","ShowModal()"); 
    

    test

    <script>
    function ShowModal()
    {
    var src = "http://sample.com/";
    $.modal('<iframe src="' + src + '" height="450" width="830" style="border:0">', {
     closeHTML: "",
     containerCss: {
      backgroundColor: "#fff",
      borderColor: "#fff",
      height: 450,
      padding: 0,
      width: 830
     },
     overlayClose: true
    });
    }
    </script>