It is possible to use the single click feature with a split button? I'm having trouble with this.
If you run the following code, you'll see the split button feature working. The split section of the button invokes the context menu for changing the button's text and command. The main part of the button does a postback. Each time a postback is done the server-side code displays the button's commandname. For example, I can run the page, choose "Save and Start Another" and keep clicking it. It stays on "Save and Start Another" after the postback.
But... if you uncomment the two lines of javascript, the Single Click feature starts working as expected. But now if I choose "Save and Start Another" from the context menu then do a postback, it reverts back to "Save and Return to List". It seems like the set_enabled(false) is causing the button's commandname to revert back to it's default/declared value. The commandname set on the clientside is lost.
If you run the following code, you'll see the split button feature working. The split section of the button invokes the context menu for changing the button's text and command. The main part of the button does a postback. Each time a postback is done the server-side code displays the button's commandname. For example, I can run the page, choose "Save and Start Another" and keep clicking it. It stays on "Save and Start Another" after the postback.
But... if you uncomment the two lines of javascript, the Single Click feature starts working as expected. But now if I choose "Save and Start Another" from the context menu then do a postback, it reverts back to "Save and Return to List". It seems like the set_enabled(false) is causing the button's commandname to revert back to it's default/declared value. The commandname set on the clientside is lost.
<
telerik:RadCodeBlock
ID
=
"RadCodeBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function OnClientSplitButton2Clicked(sender, args) {
if (args.IsSplitButtonClick()) {
var currentLocation = $telerik.getLocation(sender.get_element());
var contextMenu = $find("<%=RadContextMenu2.ClientID%>");
contextMenu.showAt(currentLocation.x, currentLocation.y + 22);
sender.set_autoPostBack(false);
}
else {
sender.set_autoPostBack(true);
//sender.set_enabled(false);
//sender.set_text("Saving...");
}
}
function OnClientContextMenu2Clicked(sender, args) {
var itemText = args.get_item().get_text();
var splitButton = $find("<%=SplitButton2.ClientID%>");
if (itemText == "Save and Return to List") {
splitButton.set_text("Save and Return to List");
splitButton.set_commandName("SaveReturn");
}
else if (itemText == "Save and Start Another") {
splitButton.set_text("Save and Start Another");
splitButton.set_commandName("SaveStartAnother");
}
}
</
script
>
</
telerik:RadCodeBlock
>
<
br
/>
<
br
/>
<
asp:Label
ID
=
"lblMessage"
runat
=
"server"
Text
=
""
Style
=
"font-size: 12pt; color: Red;"
></
asp:Label
>
<
br
/>
<
br
/>
<
telerik:RadButton
ID
=
"SplitButton2"
AutoPostBack
=
"false"
runat
=
"server"
Text
=
"Save and Return to List"
EnableSplitButton
=
"true"
Height
=
"22px"
Enabled
=
"true"
CommandName
=
"SaveReturn"
UseSubmitBehavior
=
"false"
OnClientClicked
=
"OnClientSplitButton2Clicked"
OnClick
=
"SplitButton2_Click"
>
</
telerik:RadButton
>
<
div
style
=
"display: none;"
>
<
telerik:RadContextMenu
ID
=
"RadContextMenu2"
runat
=
"server"
OnClientItemClicked
=
"OnClientContextMenu2Clicked"
EnableRoundedCorners
=
"true"
>
<
Items
>
<
telerik:RadMenuItem
Text
=
"Save and Return to List"
>
</
telerik:RadMenuItem
>
<
telerik:RadMenuItem
Text
=
"Save and Start Another"
>
</
telerik:RadMenuItem
>
</
Items
>
</
telerik:RadContextMenu
>
</
div
>
protected
void
SplitButton2_Click(
object
sender, EventArgs e)
{
lblMessage.Text =
"Save with this command: "
+ SplitButton2.CommandName +
" "
+ DateTime.Now.ToLongTimeString();
}