Setting the default submit button without an asp:panel
I have a page with user controls getting dynamically added. Inside some of these user controls there are form开发者_Go百科 elements, either simple <input>
tags or complex third party controls (Telerik RadDatePicker for example) (technical details at end).
These controls are currently being identified as part of the same form based on a ValidationGroup string setting. My question is how can I get these form elements to submit on Enter
together and raise the right postback event?
I cannot use the DefaultButton panel property because I don't have the id of the submit button available within the controls server-side. I think I might be able to use jquery clientside like this:
<input onKeyPress="javascript:if (event.keyCode == 13) {$(this).change(); $('#submitclientid').click();}" ...>
But I don't know how to do that for the third party controls.
Further technical details:
Each form element is in a separate DNN module. Inter-module communication can be used to pass around data server side which results in multiple modules working together as part of a single logical form on a page.Apparently the only way to do this is via client side JS as suggested in the question (you can however skip the jquery and instead use __dopostback
).
Have you tried setting the DefaultButton
property of Form
?
Example:
<form defaultButton="myButtonControl" runat="server">
...
</form>
By code.
aspx: 1 form (form1), 2 buttons (Button1 & Button2)
aspx.cs:
protected void Page_Load(object sender, System.EventArgs e)
{
form1.DefaultButton = Form.FindControl("Button2").UniqueID;
}
精彩评论