I am trying to figure out the best way to do replicate with the RadButton something I do with regular ASP.NET buttons. Basically I have a client script in my master page like this where a function takes a parameter to do some validation dynamically based on conditions. Its in the master page so I can have it centralized to one location for all my pages.
Here is my normal button code.
So the button passes to my function the validation group it should run before it tries to show a Rad Window that covers the entire screen modally to prevent users from clicking anything while the page process. The problem I have with the RadButton is that the OnClientClicked does not allow me to put the call in with parameters. So I thought well my solution might be that on the client side I read the source button's validation group. However, there is not clientside function for this. This best I have is to use the command argument like this.
Then to do a client side script like this.
Of course now if I run into a situation where I actually need to use the command argument on the server side I am in trouble. I ran into a similar problem where I needed a rad button to pass several parameters to a script, but again I had to use the command argument with a delimited string. It seems either the OnClientClicked needs to work more like the normal button OnClick or there needs to be some property to read parameters for the script or even expose things like the validation group property or so on.
function
Master_PerformFullPostBackWaitScreen(ValidationGroup) {
var
valid =
true
;
if
(Master_ByPassPostBackWaitScreen) {
Master_ByPassPostBackWaitScreen =
false
;
return
;
}
var
rwMasterPage_FullScreenWaitWindow = $find(
'<%=rwMasterPage_FullScreenWaitWindow.ClientID %>'
);
if
(ValidationGroup !=
null
) {
Page_ClientValidate(ValidationGroup);
valid = Page_IsValid;
}
if
((rwMasterPage_FullScreenWaitWindow !=
null
) && (valid)) rwMasterPage_FullScreenWaitWindow.show();
}
Here is my normal button code.
<
telerik:Button
ID
=
"btnCustomerProfile_AccountInformationSave"
runat
=
"server"
Text
=
"Save"
onclick
=
"btnCustomerProfile_AccountInformationSave_Click"
ValidationGroup
=
"vgAccountInformation"
Visible
=
"false"
OnClientClick
=
"Master_PerformFullPostBackWaitScreen('vgAccountInformation')"
/>
So the button passes to my function the validation group it should run before it tries to show a Rad Window that covers the entire screen modally to prevent users from clicking anything while the page process. The problem I have with the RadButton is that the OnClientClicked does not allow me to put the call in with parameters. So I thought well my solution might be that on the client side I read the source button's validation group. However, there is not clientside function for this. This best I have is to use the command argument like this.
<
telerik:RadButton
ID
=
"btnCustomerProfile_AccountInformationSave"
runat
=
"server"
Text
=
"Save"
onclick
=
"btnCustomerProfile_AccountInformationSave_Click"
ValidationGroup
=
"vgAccountInformation"
Visible
=
"false"
OnClientClicked
=
"Master_PerformFullPostBackWaitScreen_RadButton"
CommandName
=
"Save"
CommandArgument
=
"vgAccountInformation"
Icon-PrimaryIconUrl
=
"../images/icons/save16x16.gif"
/>
Then to do a client side script like this.
function
Master_PerformFullPostBackWaitScreen_RadButton(sender, eventArgs) {
Master_PerformFullPostBackWaitScreen(sender.get_commandArgument())
}
Of course now if I run into a situation where I actually need to use the command argument on the server side I am in trouble. I ran into a similar problem where I needed a rad button to pass several parameters to a script, but again I had to use the command argument with a delimited string. It seems either the OnClientClicked needs to work more like the normal button OnClick or there needs to be some property to read parameters for the script or even expose things like the validation group property or so on.