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

newbie -> how to display alert/message box on successful delete

3 Answers 438 Views
Window
This is a migrated thread and some comments may be shown as answers.
Ice
Top achievements
Rank 1
Ice asked on 04 Sep 2008, 01:06 PM
hello

i m a total newbie to telerik controls, can u plz provide me step-by-step guide on how to display a alert/message box, after record delete statement in code-behind.

i m getting bit confused with different ways explained in the forum, so can u plz let me know which all controls should i include and how to display the window

3 Answers, 1 is accepted

Sort by
0
Obi-Wan Kenobi
Top achievements
Rank 1
answered on 04 Sep 2008, 02:02 PM
I created for you an example which illustrates how to show alert after postback/ajax.
ASPX:
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server">  
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server">  
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 
    <div> 
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager> 
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">  
        <ContentTemplate> 
                <asp:Button ID="btnShowAlertAfterAjax" runat="server" Text="ShowAlertAfterAjax" OnClick="btnShowAlertAfterAjax_Click"/>  
        </ContentTemplate> 
    </asp:UpdatePanel> 
    <asp:Button ID="btnShowAlertAfterPostback" runat="server" Text="ShowAlertAfterPostback" OnClick="btnShowAlertAfterPostback_Click"/>  
    </div> 
    </form> 
</body> 
</html> 
Codebehind:
 protected void Page_Load(object sender, EventArgs e)  
    {  
 
    }  
    protected void btnShowAlertAfterAjax_Click(object sender, EventArgs e)  
    {  
        //....DO SOMETHING  
        string textAlert="AFTER AJAX:ALERT!!!";  
        ScriptManager.RegisterStartupScript(  
               UpdatePanel1,  
               this.GetType(),  
               "ShowAlert",  
               string.Format(@"function _showAlert() {{  
    Sys.Application.remove_load(_showAlert);  
    radalert('{0}!', 330, 100);   
}};  
Sys.Application.add_load(_showAlert);", textAlert), true);  
 
 
    }  
    protected void btnShowAlertAfterPostback_Click(object sender, EventArgs e)  
    {  //DO SOmething
        string textAlert="AFTER POSTBACK:ALERT!!!";  
        string myScript = string.Format(@"function _showAlert() {{  
    Sys.Application.remove_load(_showAlert);  
    radalert('{0}!', 330, 100);   
}};  
Sys.Application.add_load(_showAlert);", textAlert);  
        Page.ClientScript.RegisterStartupScript(this.GetType(), "Show alert", myScript,true);  
    } 

Hope this helps!
0
Michael
Top achievements
Rank 1
answered on 28 Jan 2009, 08:56 PM
I followed this example and it seems to work satisfactorally.  However, I am unable to get the iinput value in the prompt (in the example =42) to generate a postback.   holdfield gets the 42, but no postback occurs.    Is the another way I could be doing this.

 

<asp:TextBox ID="holdfield" AutoPostBack="true" runat="server" ontextchanged="holdfield_TextChanged" ></asp:TextBox>

 

 


 

function promptCallBackFn(arg) {

 

document.getElementById((

"<%=holdfield.ClientID %>")).innerText = arg;

 

 

 

}

 

 

0
Georgi Tunev
Telerik team
answered on 29 Jan 2009, 07:13 AM
Hello Michael,

radalert, radprompt and radconfirm are called and handled on the client only - just like the standard alert, prompt and confirm dialogs from the browser.
Note that once you receive the argument on the client, you can perform a postback in the javascript handler by using the built - in javascript __doPostBack function - you can find more information about it here. As an alternative you can also perform an ajax request if this is suitable for your scenario because this will make the page performance better and the unpleasant flickering when loading the page after a postback will disappear. You can do this by using the RadAjaxManager control and its ajaxRequest function .

All the best,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Window
Asked by
Ice
Top achievements
Rank 1
Answers by
Obi-Wan Kenobi
Top achievements
Rank 1
Michael
Top achievements
Rank 1
Georgi Tunev
Telerik team
Share this question
or