Solved

Simple jQuerry Question

Posted on 2013-01-09
6
294 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 12

Expert Comment

by:sivagnanam chandrakanth
ID: 38761765
Try this

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

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
How To Reduce Deployment Times With Pre-Baked AMIs

Even if we can't include all the files in the base image, we can sometimes include some of the larger files that we would otherwise have to download, and we can also sometimes remove the most time-consuming steps. This can help a lot with reducing deployment times.

 
LVL 19

Accepted Solution

by:
Albert Van Halen earned 500 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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

617 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