Gives solution for any Error occurs in any Programming Language, .Net Core 3.1, 3.0, C#,Asp.Net,Sqlserver,MVC,Java,Php,Html,Css,Jquery,errors and solutions,Latest News,Technology

Wednesday, 3 February 2016

MultiView Validation Issue Solution In ASP.Net,C#

No comments :
Problem :
In Asp.Net MutltiView you create two or views in one view there will be an textbox and dropdowns and another views also with some controls.Here if you are in second view and click submit button the first view validation will not be displayed.

Solution :
Here for this problem you have to mention ValidationGroup property for RequiredFieldValidator and Button and also second view.
Here I have two buttons General Info and Other Info
General Info act as a View1 and Other Info act as a View2. You have to write a property ValidationGroup to Other Info button also it should check View1 (General Info) validations.
<div>
            <asp:Button Text="General Info" BorderStyle="None" ID="GeneralInfo" CssClass="Initial" runat="server" OnClick="GeneralInfo_Click" />

            <asp:Button Text="Other Info" BorderStyle="None" ID="OtherInfo" CssClass="Initial" runat="server" ValidationGroup="ValidateAssetMaster" OnClick="OtherInfo_Click" />

        
</div>

<asp:MultiView ID="MainView" runat="server">
<asp:View ID="View1" runat="server">
Name:
<asp:TextBox ID="txtName" runat="server" Width="50%" ForeColor="Black" Height="21px" Font-Size="Small"></asp:TextBox>

<asp:RequiredFieldValidator runat="server" ID="rfvtName" ControlToValidate="txtName" ValidationGroup="ValidateView" ErrorMessage="Please
Enter Name"
CssClass="errorMessgae" Display="None"></asp:RequiredFieldValidator>
</asp>

<asp:View ID="View2" runat="server">
Branch:
<asp:TextBox ID="txtBranch" runat="server" Width="50%" ForeColor="Black" Height="21px" Font-Size="Small"></asp:TextBox>

<asp:RequiredFieldValidator runat="server" ID="rfvtName" ControlToValidate="txtBranch" ValidationGroup="ValidateView" ErrorMessage="Please
Enter Name"
 CssClass="errorMessgae" Display="None"></asp:RequiredFieldValidator>

</asp>

<asp:Button Id = "btnSubmit" runat= "server" Text = "Submit" OnClick="btnSubmit_Click" ValidationGroup = "ValidateView"/>


No comments :

Post a Comment