简体   繁体   中英

ValidationGroup issue - without group: `DoPostBackWithOptions`, with group: `__dopostback`

Validation works fine until I make use of ValidationGroup. Afterward the form submits but no validation occurs. This is the href on the LinkButton before and after I use the ValidationGroup.

Before: javascript:DoPostBackWithOptions(...)

After: javascript:__doPostback(...)

The CausesValidation property is set to true. Why does adding the ValidationGroup change the postback code like that?

Once you set the validationgroup on the button, the button should only trigger the matched group validator.

ASP.Net generates WebForm_DoPostBackWithOptions is because there is a group validator on your page matching with your button's attribute 'validationGroup'.

Your link button markup code should be similar like that:

    <input type="submit" name="btnGroup1" value="Group1" onclick="javascript:WebForm_DoPostBackWithOptions(
new WebForm_PostBackOptions('btnGroup1', '', true,'Group1','', false, false))" id="btnGroup1" />

Through debugging the js code, you should be able to find there is a js function used to find group validator. This function will validate if 'Group1' validator is there.

Debug this js method see if it can find your specified group validator.

IsValidationGroupMatch

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM