Show msgbox after save data in behide code

4 posts, 0 answers
  1. Teera
    Teera avatar
    2 posts
    Member since:
    Aug 2012

    Posted 19 Jul 2010 Link to this post

    I  want to show msgbox after save data to  database  and not show msgbox when post back again after save data.
    Now I use "RadAjaxManager1.ResponseScripts.Clear()"  for clear msgbox .. but  msgbox show alway after save data..
    Pls help me ..

    Page Load
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load   
            If Not Page.IsPostBack Then  
                ConnectPreFix()
                ConnectUserGroup()
                CheckLevelGroup(gLevel)
                 .....
            Else
                RadAjaxManager1.ResponseScripts.Clear()
            End If  
        End Sub

    Insert Data

     

    Sub InsertData()
      Dim Result As Boolean
     Try
       StrSql="..."
       Result = DbPortal.QueryExecuteNonQuery(StrSql)
        ....
       Catch ex As Exception
                LblError.Text = " InsertData :" & ex.Message
                PanelError.Visible = True  
       Finally           
                ShowMsg("Insert Data Complete !")
                PanelError.Visible = False
       End Try

     

    End Sub

     

     

     

    Show Msg

     

     

    Sub ShowMsg(ByVal sMsg As String  
    RadAjaxManager1.ResponseScripts.Add("Sys.Application.add_load(function()" & Chr(13)& "" & Chr(10) & " {radalert('" & sMsg & "', 330, 210);})"  
    End Sub

     

     

     



     

  2. Petio Petkov
    Admin
    Petio Petkov avatar
    825 posts

    Posted 20 Jul 2010 Link to this post

    Hi Teera,
     
    You don't need to add "Sys.Application.add_load...". Your method should look like this one:

    RadAjaxManager1.ResponseScripts.Add(@"radalert('RadWindow <b>Prometheus</b>!', 330, 210);")

    More about calling radalert from codebehind is available in the following KB article:
    http://www.telerik.com/support/kb/aspnet-ajax/window/calling-radalert-from-codebehind.aspx

    Let us know if you have any other questions.


    Sincerely yours,
    Petio Petkov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Teera
    Teera avatar
    2 posts
    Member since:
    Aug 2012

    Posted 20 Jul 2010 Link to this post

    Hi Telerik team 
     Thank you, now I calling radalert by
    "RadAjaxManager1.ResponseScripts.Add("radalert('Welcome to RadWindow <b>Prometheus</b>!', 330, 210);")
     but  java error   Message: 'undefined' is null or not an object    Telerik.Web.UI.WebResource.axd
     
  4. Petio Petkov
    Admin
    Petio Petkov avatar
    825 posts

    Posted 22 Jul 2010 Link to this post

    Hello Teera,

    The error means that radalert method doesn't exist on the page. In case that you didn't add a  RadWindowManager to your page - please add it.
    Here it is a simple example, which illustrates how to show radalert after Ajax call:
    ASPX:
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <head id="Head1" runat="server">
    </head>
    <body class="BODY">
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="Button1" >
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="Button1"/>
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>
        <div>
            <asp:Button ID="Button1" runat="server" Text="showAlert" OnClick="Button1_Click"/>
        </div>
        </form>
    </body>
    </html>
    Codebehind:
    protected void Button1_Click(object sender, EventArgs e)
       {
           RadAjaxManager1.ResponseScripts.Add("radalert('Welcome to RadWindow <b>Prometheus</b>!', 330, 210);");
       }
    In case that you still experience this JavaSciprt error, please open a new support thread and send us a running project, which will help us to reproduce the error locally. Once we receive it, we will do our best to help you.

    Greetings,
    Petio Petkov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top