This is a migrated thread and some comments may be shown as answers.

Show msgbox after save data in behide code

3 Answers 117 Views
Window
This is a migrated thread and some comments may be shown as answers.
Teera
Top achievements
Rank 2
Teera asked on 19 Jul 2010, 03:50 PM
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

 

 

 



 

3 Answers, 1 is accepted

Sort by
0
Petio Petkov
Telerik team
answered on 20 Jul 2010, 04:21 PM
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
0
Teera
Top achievements
Rank 2
answered on 20 Jul 2010, 05:18 PM
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
 
0
Petio Petkov
Telerik team
answered on 22 Jul 2010, 03:20 PM
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
Tags
Window
Asked by
Teera
Top achievements
Rank 2
Answers by
Petio Petkov
Telerik team
Teera
Top achievements
Rank 2
Share this question
or