Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. alert message box in update panel

alert message box in update panel

Scheduled Pinned Locked Moved ASP.NET
javascriptdebuggingtoolshelpannouncement
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    ships_agr
    wrote on last edited by
    #1

    string msg = "You cannot select more seats."; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<script type='text/javascript'>"); sb.Append("window.onload=function(){"); sb.Append("alert('"); sb.Append(msg); sb.Append("')};"); sb.Append("</script>"); ScriptManager.RegisterClientScriptBlock(this,typeof(Page), "alert", sb.ToString(),false); i tried to display the dialog box on click event of a button in update panel......but its leading to a runtime error that i'm unable to debug....please if anyone can have a look at the code and tell me if there is an error....also tell me any other necessary property of scriptmanager or update panel that i need to set ....i'm using this thing for the first time....so not much familiar with the procedure.

    B 1 Reply Last reply
    0
    • S ships_agr

      string msg = "You cannot select more seats."; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<script type='text/javascript'>"); sb.Append("window.onload=function(){"); sb.Append("alert('"); sb.Append(msg); sb.Append("')};"); sb.Append("</script>"); ScriptManager.RegisterClientScriptBlock(this,typeof(Page), "alert", sb.ToString(),false); i tried to display the dialog box on click event of a button in update panel......but its leading to a runtime error that i'm unable to debug....please if anyone can have a look at the code and tell me if there is an error....also tell me any other necessary property of scriptmanager or update panel that i need to set ....i'm using this thing for the first time....so not much familiar with the procedure.

      B Offline
      B Offline
      Brij
      wrote on last edited by
      #2

      So if you want to show the message on button click then why you assigned the function to window.onload event,I just tried your code and put it Page_Load and it was showing the alert message... :) So if you want to run it on button click the use the code below

      string msg = "You cannot select more seats.";
      System.Text.StringBuilder sb = new System.Text.StringBuilder();
      sb.Append("<script type='text/javascript'>");
      sb.Append("function ShowAlert(){");
      sb.Append("alert('");
      sb.Append(msg);
      sb.Append("'); return false;};");
      sb.Append("</script>");
      ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "alert", sb.ToString(), false);

      and button should be as

      <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="javascript:return ShowAlert();" />
      

      let me know if face any issue.

      Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators

      S 1 Reply Last reply
      0
      • B Brij

        So if you want to show the message on button click then why you assigned the function to window.onload event,I just tried your code and put it Page_Load and it was showing the alert message... :) So if you want to run it on button click the use the code below

        string msg = "You cannot select more seats.";
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        sb.Append("<script type='text/javascript'>");
        sb.Append("function ShowAlert(){");
        sb.Append("alert('");
        sb.Append(msg);
        sb.Append("'); return false;};");
        sb.Append("</script>");
        ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "alert", sb.ToString(), false);

        and button should be as

        <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="javascript:return ShowAlert();" />
        

        let me know if face any issue.

        Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators

        S Offline
        S Offline
        ships_agr
        wrote on last edited by
        #3

        Hi Brij.... Thanks for your reply... actually i'm counting the number of buttons clicked by user with the value contained in a session variable....and when the no of clicks cross that value then i wanna display the alert message....if i'll put it on "onclientclick" property then how can i get the condition checked ??

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups