Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Simple jQuerry Question

Posted on 2013-01-09
6
Medium Priority
?
297 Views
Last Modified: 2013-01-25
Can someone PLEASE tell me how to call this function from C#:

I tried doing this:

protected void myButton(object sender, EventArgs e)
{
    .....
    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "<script type='text/javascript'>MsgBox();</script>", false);
}

Open in new window


<html xmlns="http://www.w3.org/1999/xhtml">
  <meta charset="utf-8" />
  <title>jQuery UI Dialog - Animation</title>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
  <script src="/resources/demos/external/jquery.bgiframe-2.1.2.js"></script>
  <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css" />
  <script>
      function MsgBox() {
          // increase the default animation speed to exaggerate the effect
          $.fx.speeds._default = 1000;
          $(function () {
              $("#dialog").dialog({
                  autoOpen: false,
                  show: "blind",
                  hide: "explode"
              });

              $("#opener").click(function () {
                  $("#dialog").dialog("open");
                  return false;
              });
          });
      }
  </script>

</head>
<body>
 
<div id="dialog" title="Basic dialog">
  <p>This is an animated dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
 
<button id="opener">Open Dialog</button>
 
 
</body>
</html>

Open in new window

0
Comment
Question by:pauledwardian
6 Comments
 
LVL 12

Expert Comment

by:sivagnanam chandrakanth
ID: 38761765
Try this

 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "MsgBox();", true);
0
 
LVL 83

Expert Comment

by:leakim971
ID: 38761771
try this :

    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "window.onload = function() { MsgBox(); }", true);
0
 

Author Comment

by:pauledwardian
ID: 38761797
No luck with any one of them.
This is what I do:
  ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "MsgBox();", true);

Open in new window


 <meta charset="utf-8" />
  <title>jQuery UI Dialog - Animation</title>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
  <script src="/resources/demos/external/jquery.bgiframe-2.1.2.js"></script>
  <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css" />
  <script>
      function MsgBox() {
          // increase the default animation speed to exaggerate the effect
          $.fx.speeds._default = 1000;
          $(function () {
              $("#dialog").dialog({
                  autoOpen: false,
                  show: "blind",
                  hide: "explode"
              });

              $("#opener").click(function () {
                  $("#dialog").dialog("open");
                  return false;
              });
          });
      }
  </script>

Open in new window


<div id="dialog" title="Basic dialog">
  <p>This is an animated dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Expert Comment

by:Manoj Patil
ID: 38762199
0
 
LVL 19

Accepted Solution

by:
Albert Van Halen earned 1500 total points
ID: 38762396
Just remove your function wrapper.
<script type="text/javascript">
	// increase the default animation speed to exaggerate the effect
	$.fx.speeds._default = 1000;
	$(function () {
		$("#dialog").dialog({
			autoOpen: false,
			show: "blind",
			hide: "explode"
		});

		$("#opener").click(function () {
			$("#dialog").dialog("open");
			return false;
		});
	});
</script>

Open in new window

0
 

Author Closing Comment

by:pauledwardian
ID: 38820360
thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question