简体   繁体   English

FieldValidators和Visual Web部件(Sharepoint 2010)

[英]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.

相关问题 Sharepoint 2010中的自定义AnnouncementListItem可视Web部件 - Custom AnnouncementListItem Visual Web Part in Sharepoint 2010 Sharepoint 2010 Visual Web部件-当前上下文中不存在名称“ InitializeControl” - Sharepoint 2010 Visual Web Part - The name 'InitializeControl' does not exist in the current context 在可视 Web 部件中显示共享点列表值 - display sharepoint list value in visual web part 使用visual studio 2010消费sharepoint 2010 Web服务 - consuming sharepoint 2010 web service with visual studio 2010 自定义可视化 Web 部件属性 sharepoint - Custom visual web part properties sharepoint Sharepoint可视Web部件自定义设置重置 - Sharepoint visual web part custom settings resets jQuery ajax在Sharepoint Visual Web部件中不起作用 - jQuery ajax not working in Sharepoint Visual Web Part 是否可以在Web部件中使用多线程访问SharePoint 2010列表? - Is it possible to access a SharePoint 2010 list using multi threading in a web part? 在SharePoint 2010 Web部件中模拟用户以调用WCF服务 - Impersonate User in SharePoint 2010 web part to call WCF service SharePoint 2010:如何为所有用户提取个性化Web部件属性 - SharePoint 2010: How to extract personalized web part property for all users
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM