[英]FieldValidators and Visual Web Part (Sharepoint 2010)
I have a visual web part (a simple form) with RequiredFieldValidators. 我有一个带有RequiredFieldValidators的可视化Web部件(一种简单形式)。 But a problem has occured since the field validators block editing of the page.
但是,由于字段验证器阻止了页面的编辑,因此出现了问题。 When i press Edit Page in Sharepoint it starts to load then the validators fire and the javascript is stopped.
当我在Sharepoint中按“编辑页面”时,它开始加载,然后验证器启动,并且javascript停止。
I found a solution but i cant get it to work. 我找到了解决方案,但无法正常工作。
Like this 像这样
public override void CreateChildControls()
{
if(SPContext.Current.FormContext.FormMode == SPControlMode.Edit)
((UserControl)_ctl).EnableValidators(false);
((UserControl)_ctl).EnableValidators(true);
}
//But the _ctl does not exit i only have
Control control = Page.LoadControl(_ascxPath);
A litte advice would help this sharepoint noob a great deal. 少量建议将对这个共享点菜鸟有很大帮助。
The form is just Labels, Inputs, a button, updatepanel and requiredFieldValidators 表单只是标签,输入,按钮,updatepanel和requiredFieldValidators
Can you not just set the ValidationGroup for the validators and button? 您不仅可以为验证器和按钮设置ValidationGroup吗? Like this: http://msdn.microsoft.com/en-us/library/ms227424.aspx
像这样: http : //msdn.microsoft.com/en-us/library/ms227424.aspx
The validators should only fire when the button is pressed. 验证器仅应在按下按钮时触发。
There is something wrong with your configuration - I tested this configuration and the required field validators definitely don't block editing on the page. 您的配置有问题-我测试了此配置,所需的字段验证器绝对不会阻止页面上的编辑。 Do you want to post your page and your code behind?
您要发布页面和代码吗? Might help to troubleshoot the problem.
可能有助于解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.