I have a RadWindow which inserts a new record in a database. When I finish the insert and close the window, I want the new item to be added/refreshed to an existing DropDownList on the Parent page.
How would I do this (without the parent page requiring a postback)?
How would I do this (without the parent page requiring a postback)?
3 Answers, 1 is accepted
0
Accepted
Princy
Top achievements
Rank 2
answered on 22 Sep 2009, 05:54 AM
Hello,
Add RadAjaxManager on page so that you can call the AjaxRequest from "OnClientClose" event of RadWindow. Then add the new items in dropdownlist inside the "RadAjaxManager1_AjaxRequest" method. See the sample code shown below in order to achieve this.
ASPX:
C#:
Thanks,
Princy.
Add RadAjaxManager on page so that you can call the AjaxRequest from "OnClientClose" event of RadWindow. Then add the new items in dropdownlist inside the "RadAjaxManager1_AjaxRequest" method. See the sample code shown below in order to achieve this.
ASPX:
<telerik:RadWindowManager ID="RadWindowManager1" runat="server"> |
<Windows> |
<telerik:RadWindow runat="server" OnClientClose="closeRadWindow" Behavior="Default" InitialBehavior="None" |
Left="" NavigateUrl="window.aspx" OpenerElementID="Button1" > |
</telerik:RadWindow> |
</Windows> |
</telerik:RadWindowManager> |
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" |
onajaxrequest="RadAjaxManager1_AjaxRequest"> |
<AjaxSettings> |
<telerik:AjaxSetting AjaxControlID="RadGrid1"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="RadGrid1" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
<telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="Dropdown1" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
</AjaxSettings> |
</telerik:RadAjaxManager> |
<script type="text/javascript"> |
function closeRadWindow() |
{ |
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest(); |
} |
</script> |
C#:
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) |
{ |
//Add items to dropdown1 |
} |
Thanks,
Princy.
0
darenkov
Top achievements
Rank 1
answered on 22 Sep 2009, 07:12 AM
Thanks, that works. Nice and easy.
I use the Ajax Manager for multiple controls however, so I need to pass two arguments into the AjaxManager, ie the name of the control to refresh, and the id of the ListItem to set in the DDL.
I have figured out how to pass one argument to the AjaxManager, but not sure what is the best way to pass 2 arguments. I created an object in javascript, but then in .NET it comes in as a generic object. Am I on the right track, or should I just pass a string and split them?
I use the Ajax Manager for multiple controls however, so I need to pass two arguments into the AjaxManager, ie the name of the control to refresh, and the id of the ListItem to set in the DDL.
I have figured out how to pass one argument to the AjaxManager, but not sure what is the best way to pass 2 arguments. I created an object in javascript, but then in .NET it comes in as a generic object. Am I on the right track, or should I just pass a string and split them?
0
Shinu
Top achievements
Rank 2
answered on 22 Sep 2009, 07:45 AM
Hi Darenkov,
Surely, you can pass the argument for ajaxRequest(), for which the control had used when it raised the request as shown below.
ajaxManager.ajaxRequest(argument); // Pass the argument
And in the code behind:
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
if (e.Argument.ToString() == "RequestArgument")
{
// Your code
}
}
-Shinu.
Surely, you can pass the argument for ajaxRequest(), for which the control had used when it raised the request as shown below.
ajaxManager.ajaxRequest(argument); // Pass the argument
And in the code behind:
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
if (e.Argument.ToString() == "RequestArgument")
{
// Your code
}
}
-Shinu.