开发者

Validation Control is not working under SandBox Solution

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜