Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class bgchange : IMapServerDropDownBoxAction
- {
- void IServerAction.ServerAction(ToolbarItemInfo info)
- {
- Some code...
- [WebMethod]
- public static void DoSome()
- {
- }
- public class bgchange : IMapServerDropDownBoxAction
- {
- void IServerAction.ServerAction(ToolbarItemInfo info)
- {
- ...my C# code to perform on dropdown selection...
- //now I want to trigger some javascript...
- // Define the name and type of the client scripts on the page.
- String csname1 = "PopupScript";
- Type cstype = this.GetType();
- // Get a ClientScriptManager reference from the Page class.
- ClientScriptManager cs = Page.ClientScript;
- // Check to see if the startup script is already registered.
- if (!cs.IsStartupScriptRegistered(cstype, csname1))
- {
- String cstext1 = "alert('Hello World');";
- cs.RegisterStartupScript(cstype, csname1, cstext1, true);
- }
- }
- <asp:ScriptManager ID="scriptManager1"
- runat="server" EnablePageMethods="true" />
- Page.ClientScript.RegisterStartupScript(
- this.GetType(),
- "callDoSome",
- "PageMethods.DoSome(Callback_Function, null)",
- true);
- <script language="javascript" type="text/javascript">
- function Callback_Function(result, context) {
- alert('WebMethod was called');
- }
- </script>
- public void ServerAction(ToolbarItemInfo info) {
- string jsfunction = "alert('Hello');";
- Map mapctrl = (Map)info.BuddyControls[0];
- CallbackResult cr = new CallbackResult(null, null, "javascript", jsfunction);
- mapctrl.CallbackResults.Add(cr);
- }
- string script = "<script language='javascript'>n";
- script += "javascriptFunctionHere();n";
- script += "</script>";
- Page.RegisterStartupScript("ForceClientToCallServerMethod", script);
- public partial class _Default : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- Page.ClientScript.RegisterStartupScript(
- this.GetType(),
- "helloworldpopup",
- "alert('hello world');",
- true);
- }
- }
Add Comment
Please, Sign In to add comment