Hi,
I have a page to add new event details and add user details.
When selecting Third Party /Visitor on Person Reporting drop down box, Add New user button pops up and when clicked it opens up modal form to create visitor information and should save the data in the sql data base. Then should allow to complete the event detail add to the sql database
But when I click on Save button on modal form main form's field required validation. But I need to validate two forms independently and save the data into sql database
How can I avoid this and validate modal form fields separately and insert into data base?
Kindly help me to fix this issue
Thank you in advance for your help
Kind Regards,
Harinda
<!-- add event form-->
<div class="col-md-6">
<div class="tile">
<h3 class="tile-title">Add Event</h3>
<div class="tile-body">
<div class="form-group row">
<label class="control-label col-md-3">Type of Event</label>
<div class="col-md-8">
<asp:DropDownList ID="ddTypeofEvent" runat="server" class="form-control">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Hazard/Observation</asp:ListItem>
<asp:ListItem>Risk</asp:ListItem>
<asp:ListItem>Near Miss</asp:ListItem>
<asp:ListItem>Incident</asp:ListItem>
<asp:ListItem>Illness</asp:ListItem>
<asp:ListItem>Injury</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator runat="server" ErrorMessage="*Required" ControlToValidate="ddTypeofEvent" ForeColor="Red"></asp:RequiredFieldValidator>
</div>
</div>
<div class="form-group row">
<label class="control-label col-md-3">Person Reporting</label>
<div class="col-md-8">
<asp:DropDownList ID="ddPersonReporting" runat="server" class="form-control" AutoPostBack="true" OnSelectedIndexChanged="DropDownList_Changed">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Worker</asp:ListItem>
<asp:ListItem>Contracted Worker</asp:ListItem>
<asp:ListItem>Third Party /Visistor</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator runat="server" ErrorMessage="*Required" ControlToValidate="ddPersonReporting" ForeColor="Red"></asp:RequiredFieldValidator>
<asp:Button ID="btnAdd1" class="btn btn-primary" runat="server" Text="Add Visitor" data-toggle="modal" CausesValidation="False" data-target="#MyPopup" Visible="False" data-backdrop='static' data-keyboard='false' />
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#MyPopup" data-backdrop='static' data-keyboard='false'>
Add User</button>
</div>
</div>
<div class="form-group row">
<label class="control-label col-md-3">Reporter Name</label>
<div class="col-md-8">
<asp:DropDownList ID="ddreporterName" runat="server" class="form-control col-md-8">
</asp:DropDownList>
<asp:RequiredFieldValidator runat="server" ErrorMessage="*Required" ControlToValidate="ddreporterName" ForeColor="Red"></asp:RequiredFieldValidator>
</div>
</div>
<div class="form-group row">
<label class="control-label col-md-3">Upload Picture</label>
<div class="col-md-8">
<asp:FileUpload ID="flppicture" runat="server" class="form-control col-md-8" placeholder="Select File to upload"></asp:FileUpload>
<asp:Label ID="lblpath" runat="server" Visible="False" class="form-control col-md-8" CssClass="auto-style1"></asp:Label>
<asp:TextBox ID="textbox1" runat="server" Visible="False"></asp:TextBox>
</div>
</div>
<div class="tile-footer">
<div class="row">
<div class="auto-style1">
<asp:Button ID="cmdSave" type="submit" runat="server" Text="Save" class="btn btn-primary" OnClick="AddIncident"></asp:Button>
<asp:Button ID="cmdCancel" runat="server" class="btn btn-secondary" href="#" Text="Cancel" CausesValidation="False"></asp:Button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Modal Popup -->
<div class="modal" id="MyPopup">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Modal title</h5>
<button class="close" type="button" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
<p>Modal body text goes here.</p>
<label for="lblFullName">
Full Name</label>
<asp:TextBox ID="txtFullName" type="text" runat="server" class="form-control" placeholder="Enter Full Name"></asp:TextBox>
<br />
<label for="lblEmail">
Email</label>
<asp:TextBox ID="txtEmail" type="email" runat="server" class="form-control" placeholder="Enter Email"></asp:TextBox>
<br />
<label for="lblPassword">
Password</label>
<asp:TextBox ID="txtPassword" type="password" runat="server" class="form-control" placeholder="Enter Password" title="Password must contain: Minimum 8 characters atleast 1 Alphabet and 1 Number"></asp:TextBox>
<br />
<label for="lblConfirmPassword">
Confirm Password</label>
<asp:TextBox ID="txtConfirmPassword" type="password" runat="server" class="form-control" placeholder="Confirm Password"></asp:TextBox>
<br />
<label for="lblusergroup">
User Group</label>
<asp:DropDownList ID="ddusergroup" runat="server" class="form-control" placeholder="Select User Group">
<asp:ListItem></asp:ListItem>
<asp:ListItem>User</asp:ListItem>
<asp:ListItem>Supervisor</asp:ListItem>
<asp:ListItem>Admin</asp:ListItem>
<asp:ListItem>Guest</asp:ListItem>
</asp:DropDownList>
<br />
<label for="lblReportingManager">
Reporting Manager</label>
<asp:DropDownList ID="ddReportingManager" runat="server" class="form-control" placeholder="Reporting Manager">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Mgr1</asp:ListItem>
<asp:ListItem>Mgr2</asp:ListItem>
<asp:ListItem>Mgr3</asp:ListItem>
<asp:ListItem>None</asp:ListItem>
</asp:DropDownList>
<br />
<asp:Button ID="CmdCreateNewUser" type="submit" runat="server" Text="Create" class="btn btn-primary" OnClick="RegisterUser" />
<asp:Button ID="btnClose" Text="Close" runat="server" CausesValidation="False" class="btn btn-secondary" data-dismiss="modal" />
<br />
<div class="clearfix"></div>
</div>
</div>
<div class="modal-footer">
</div>
</div>
</div>
<!-- Modal Popup -->