开发者

Setting the default submit button without an asp:panel

开发者 https://www.devze.com 2022-12-28 23:05 出处:网络
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 (T

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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号