0

If i have script like this :

<script type="text/javascript" src="//www.gmodules.com/ig/ifr?url=http://hosting.gmodules.com/ig/gadgets/file/100080069921643878012/facebook.xml&amp;up_useNewFB_p=1&amp;up_showPopUp2_p=true&amp;synd=open&amp;w=320&amp;h=500&amp;title=Facebook&amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;output=js"></script>

and i wanna to execute this script in specific time in my .cs code how to do this?

Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392
  • 3
    C# code runs on the server side, and that script will be loaded in the client side, in what "specific time" would you like it to run? – Nitzan Tomer Mar 08 '12 at 09:03
  • I check on some value in comes from the `db` and then i wanna to execute this script which will create a `gadget` in the required place on my page – Anyname Donotcare Mar 08 '12 at 09:06

3 Answers3

1
string rowTestHide = @"<script type="text/javascript" src="//www.gmodules.com/ig/ifr?url=http://hosting.gmodules.com/ig/gadgets/file/100080069921643878012/facebook.xml&amp;up_useNewFB_p=1&amp;up_showPopUp2_p=true&amp;synd=open&amp;w=320&amp;h=500&amp;title=Facebook&amp;
border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;output=js"></script>";
ClientScript.RegisterStartupScript(this.GetType(),"rowTest", rowTestHide);
SmartestVEGA
  • 8,415
  • 26
  • 86
  • 139
1

Try out with following code,

Page.ClientScript.RegisterClientScriptInclude("MyScript", "<script type="text/javascript" src="//www.gmodules.com/ig/ifr?url=http://hosting.gmodules.com/ig/gadgets/file/100080069921643878012/facebook.xml&amp;up_useNewFB_p=1&amp;up_showPopUp2_p=true&amp;synd=open&amp;w=320&amp;h=500&amp;title=Facebook&amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;output=js"></script>");
1

The only real way to do this at the moment (without using something like SignalR) is to implement a polling system.

You will have to have an Ajax call, that makes a request to your server every xxx seconds, using something like:

window.setTimeout(function(){ /* do ajax request */ }, 5000);

Which would run every 5 seconds.

If the desired result comes back from the DB, you'll have to then programatically inject the required script block into your page.

take a look at this: jQuery AJAX polling for JSON response, handling based on AJAX result or JSON content

Community
  • 1
  • 1
Dave Bish
  • 19,263
  • 7
  • 46
  • 63