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

How to show a popup message via Rad alert or Java Script Function

3 Answers 420 Views
Grid
This is a migrated thread and some comments may be shown as answers.
gc_0620
Top achievements
Rank 1
gc_0620 asked on 04 Feb 2010, 01:59 AM
Hi,

Environment: RadControls for ASP.NET AJAX Q3 2009 / VS 2008 SP1/IE7/WINXP SP 2. 

I am using Master Detail Form Template for Insert updates.. Below is my form Template Insert/Update Command..

 

<td align="right" colspan="2">  
                                        <asp:Button ID="btnUpdate" runat="server" CssClass="form-button"   
                                            CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'   
                                            Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'   
                                           /> 
                                        &nbsp;  
                                        <asp:Button ID="btnCancel" runat="server" CausesValidation="False" CssClass="form-button"   
                                            CommandName="Cancel" Text="Cancel" /> 
                                    </td> 

My Question is that on Update Event how can I show a Popup Rad Alert or Javascript Alert..  Below is my Update Command...

protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)  
    {  
         ...
          if (id == 0)  
            // if (result != null)  
            {  
 
                SqlDataSource2.UpdateParameters["Program"].DefaultValue = combo.SelectedItem.Text;  
 
                e.Canceled = false;  
            }  
            else  
            {  
            string user = "John Doe";  

 

            string stlocation = "Your Location"; 

 
                RadAjaxPanel1.ResponseScripts.Add(string.Format("alert('Location already exists for the selected user');"));  
 
                e.Canceled = true;  
 
 
            }  
             
    } 
 
Instead of showing the alert:

Location already exists for the selected user

 

I would like to show:

John Doe, Location already exists for the selected user from:  Your Location. . 

As you will notice, I stored John Doe in string user and Your Location in stlocation..

Is it possible this can be done via a Javscript Function and this whole string "John Doe, Location already exists for the selected user from:  Your Location" can be pass as argument or parameter.  This way I can call the same Function over and over from other events just by passing the parameter.  


Thanks

GC_0620

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Feb 2010, 04:58 AM
Hello,

You can follow the method described in the KB Article, in order to show radalert from code behind.
Calling radalert from codebehind

Hope this helps, :)
Princy.
0
gc_0620
Top achievements
Rank 1
answered on 05 Feb 2010, 12:58 AM
Thanks Princy but the link you mentioned requires a button click. I want a popup alert (Rad or Java script) without binding to any button click event.

I believe I saw a thread either from you or Shinu how to achieve this funtionality. I believe it was how to popup RequiredFieldValidator messages via Javascript (i.e. Calling Javascript function with that message as parameter).

Thanks

GC_0620
0
Pavlina
Telerik team
answered on 10 Feb 2010, 09:11 AM
Hello,

Attached to this message is a simple working application which handles a similar functionality. Please
examine it and let me know if it works for you.

I hope this helps.

Best wishes,
Pavlina
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
Grid
Asked by
gc_0620
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
gc_0620
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or