开发者

Validation Control is not working under SandBox Solution

开发者 https://www.devze.com 2023-02-22 13:52 出处:网络
I am working on SandBox solution(SharePoint 2010). Below is my code [ToolboxItemAttribute(false)] public class TestValidationControl : WebPart

I am working on SandBox solution(SharePoint 2010). Below is my code

[ToolboxItemAttribute(false)]
public class TestValidationControl : WebPart
{
    protected override void CreateChildControls()
    {
        Label lblApplicationTitle = new Label();
        lblApplicationTitle.Text = "Application Title";
        this.Controls.Add(lblApplicationTitle);

        RequiredFieldValidator rfvApplicationTitle = new RequiredFieldValidator();
        rfvApplicationTitle.ControlToValidate = "txtApplicationTitle";
        rfvApplicationTitle.ErrorMessage = "*";
        rfvApplicationTitle.EnableClientScript = true;
        this.Controls开发者_如何转开发.Add(rfvApplicationTitle);

        TextBox txtApplicationTitle = new TextBox();
        txtApplicationTitle.ID = "txtApplicationTitle";
        this.Controls.Add(txtApplicationTitle);

        Button btnSave = new Button();
        btnSave.Text = "Save";
        btnSave.CausesValidation = true;
        this.Controls.Add(btnSave);
    }
}

When I click on Save Button page gets post back. Page should not be postback if i am not entering under text box.


May be using ValidationGroup property make it works fine

0

精彩评论

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

关注公众号