Change RadWindow’s Title from Javascript or from Client-side
May 24, 2011 Leave a comment
As per my scenario, I have RadGrid which contains Add and Edit button for Adding new record and Updated existing record respectively. On click of any of these button it will open a RadWindow which contains all my page controls. And I have a requirement to set the Title of RadWindow accordinly. I mean when user click Add button at that time RadWindow’s Title should be Add Mode and for Edit button click it should be Edit Mode.
And I found an easy way to set the Title of RadWindow from client-side, which I am going to share with you.
On Button, I have a ClientClick() event from where I am opening RadWindow, so now I am going to pass the Mode of the RadWindow in which it is going to be opened. Say for example,
OnClientClick=”openFileBuilderDialog(‘Add’);”
Here, openFileBuilderDialog is my Javascript Function, which is shown as below.
function openFileBuilderDialog(Mode) {
var wnd = $find(‘<%=RadWindow1.ClientID %>’);
if (Mode == “View”) {
wnd.set_title(“View File Information”);
}
elseif (Mode == “Edit”) {
wnd.set_title(“Edit File Information”);
}
elseif (Mode == “Add”) {
wnd.set_title(“Add File Information”);
}
wnd.show();
}
In this function,
- Get the RadWindow using its ClientID.
- Find the current mode of the RadWindow, which I have supply on appropriate button’s onClientClick event.
- Then use the “set_title” method to set the Title that we want.
- And finally called, “show” method to open the RadWindow.
That’s it.
If the content page has its own title set in the @Page directive or in the <head> section, this title will override the RadWindow’s one.
To find more methods of RadWindow and examples please follow the below link,
http://www.telerik.com/help/aspnet-ajax/window-programming-radwindow-methods.html