Attempting to populate a popup from a textbox on a webpage - javascript

I have a popup in asp.net using JavaScript that I need to display variables from text boxes on the web page. The variables are coming back blank so I believe I am missing something. I think I'm missing something in the document.getElementById either I should be using something different of I'm using it incorrectly
This is my JavaScript
<!DOCTYPE html>
<title></title>
<script type = "text/javascript">
function Confirm() {
var confirm_value = document.createElement("INPUT");
confirm_value.type = "hidden";
confirm_value.name = "confirm_value";
var ppn = document.getElementById("<%= pifPassportNbr %>")
var pid = document.getElementById("<%= pifIssueDate.Text %>")
var pil = document.getElementById("<%= pifIssueLoc.Text %>")
var ped = document.getElementById("<%= pifExpirationDate.Text %>")
if (ppn == null || pid == null || pil == null || ped == null) {
if (confirm(ppn + " " + pid + " " + pil + " " + ped)) {
confirm_value.value = "Yes";
}
else {
confirm_value.value = "No";
}
document.forms[0].appendChild(confirm_value);
}
}
</script>
This is my asp.net code
<tr>
<td style="padding-top: 5px;">
<asp:UpdatePanel ID="updPassport" runat="server" UpdateMode="Conditional" Visible="false" >
<ContentTemplate>
<asp:Table runat="server" ID="tblPassport" GridLines="Both" CellSpacing="0" BorderColor="Black" BorderStyle="Solid"
BorderWidth="1.5px" Font-Size="9pt">
<asp:TableHeaderRow VerticalAlign="Bottom" Height="20px">
<asp:TableHeaderCell ColumnSpan="2" CssClass="lblValueBlackFont" HorizontalAlign="Left" BackColor="#B0CCFF" >
&nbsp<asp:Label ID="lblPassportTbl_Title" Text="Passport Information" runat="server" />
</asp:TableHeaderCell>
<asp:TableHeaderCell ID="thcPassport_Sync" runat="server" ColumnSpan="2" CssClass="lblValueBlackFont" HorizontalAlign="Right" BackColor="#B0CCFF" >
<asp:Label ID="lblPassportSyncDate_Title" runat="server" Text="GIF Info Sync'd with TS: " Font-Size="8pt" Visible="False" />
<asp:Label ID="lblPassportSyncDate" runat="server" Font-Size="8pt" Visible="False" />
&nbsp<asp:Label ID="lblPassportSyncBy_Title" runat="server" Text="By: " Font-Size="8pt" Visible="False" />
<asp:Label ID="lblPassportSyncBy" runat="server" Font-Size="8pt" Visible="False" />
&nbsp
</asp:TableHeaderCell>
</asp:TableHeaderRow>
<asp:TableHeaderRow VerticalAlign="Bottom" HorizontalAlign="Center" CssClass="gv_Header" Font-Size="9pt">
<asp:TableHeaderCell runat="server" ID="thcPassport_Fields" Text=" Fields" />
<asp:TableHeaderCell runat="server" ID="thcPassport_TS" Text="Existing Data in Travel Studio" Width="350"/>
<asp:TableHeaderCell runat="server" ID="thcPassport_PIF" Text="Data Submitted on GIF" Width="420" />
<asp:TableHeaderCell runat="server" ID="thcPassport_Update" Text="Accept New Value" Width="75px" Font-Size="8pt"
ToolTip="When checked, TS data for the field will be updated with the data in the GIF column" />
</asp:TableHeaderRow>
<asp:TableRow VerticalAlign="Top" Font-Size="9pt" >
<asp:TableCell>
&nbsp
<asp:TextBox ID="rhNationality" runat="server" ReadOnly="True" Text="Nationality:" BorderStyle="Solid" BorderColor="White"
Font-Bold="True" Font-Size="8pt" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="tsNationality" runat="server" Text="No Existing Value" ReadOnly="True" BorderStyle="Solid" BorderColor="White" Width="75%" />
<asp:TextBox ID="tsNationalityID" runat="server" ReadOnly="True" BorderStyle="Solid" BorderColor="White" Visible="false" />
<asp:TextBox ID="tsPassportCountryID" runat="server" ReadOnly="True" BorderStyle="Solid" BorderColor="White" Visible="false"/>
<asp:TextBox ID="tsPassportID" runat="server" ReadOnly="True" BorderStyle="Solid" BorderColor="White" Visible="false" />
</asp:TableCell>
<asp:TableCell VerticalAlign="Middle">
<asp:TextBox ID="pifNationality" runat="server" Text="Nationality" BorderStyle="Solid" BorderColor="White" ToolTip="Value entered is not in available list. Please choose a correct value from the dropdown." ForeColor="Red" />
<asp:DropDownList ID="ddlNationality" runat="server" AutoPostBack="True" Width="75%" />
<asp:TextBox ID="pifNationalityID" runat="server" Text="ID" BorderStyle="Solid" BorderColor="White" Visible="false" />
<asp:TextBox ID="pifNationalityCountryID" runat="server" Text="ID" BorderStyle="Solid" BorderColor="White" Visible="false" />
</asp:TableCell><asp:TableCell HorizontalAlign="Center">
<asp:CheckBox ID="ckbNationality" runat="server" Checked="false" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow VerticalAlign="Top">
<asp:TableCell>
&nbsp
<asp:TextBox ID="rhPassportNbr" runat="server" ReadOnly="True" Text="Passport Number:" BorderStyle="Solid"
BorderColor="White" Font-Bold="True" Font-Size="8pt" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="tsPassportNbr" runat="server" Text="No Existing Value" ReadOnly="True" BorderStyle="Solid" BorderColor="White" Width="95%" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="pifPassportNbr" runat="server" Text="No Data Entered" BorderStyle="Solid" BorderColor="White" Width="95%" />
</asp:TableCell>
<asp:TableCell HorizontalAlign="Center">
<asp:CheckBox ID="ckbPassportNbr" runat="server" Checked="false" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow VerticalAlign="Top">
<asp:TableCell>
&nbsp
<asp:TextBox ID="rhPassportName" runat="server" ReadOnly="True" Text="Passport Name:" BorderStyle="Solid" BorderColor="White"
Font-Bold="True" Font-Size="8pt" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="tsPassportName" runat="server" Text="No Existing Value" ReadOnly="True" BorderStyle="Solid" BorderColor="White" Width="95%" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="pifPassportName" runat="server" Text="No Data Entered" BorderStyle="Solid" BorderColor="White" MaxLength="60" Width="100%" />
</asp:TableCell>
<asp:TableCell HorizontalAlign="Center">
<asp:CheckBox ID="ckbPassportName" runat="server" Checked="false" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow VerticalAlign="Top">
<asp:TableCell>
&nbsp
<asp:TextBox ID="rhIssueLoc" runat="server" ReadOnly="True" Text="Place of Issue:" BorderStyle="Solid" BorderColor="White"
Font-Bold="True" Font-Size="8pt" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="tsIssueLoc" runat="server" Text="No Existing Value" ReadOnly="True" BorderStyle="Solid" BorderColor="White" Width="95%" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="pifIssueLoc" runat="server" Text="No Data Entered" BorderStyle="Solid" BorderColor="White" MaxLength="50" Width="100%" />
</asp:TableCell>
<asp:TableCell HorizontalAlign="Center">
<asp:CheckBox ID="ckbIssueLoc" runat="server" Checked="false" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow VerticalAlign="Top">
<asp:TableCell>
&nbsp
<asp:TextBox ID="rhIssueDate" runat="server" ReadOnly="True" Text="Issue Date:" BorderStyle="Solid" BorderColor="White"
Font-Bold="True" Font-Size="8pt" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="tsIssueDate" runat="server" Text="No Existing Value" ReadOnly="True" BorderStyle="Solid" BorderColor="White" Width="95%" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="pifIssueDate" runat="server" Text="No Data Entered" BorderStyle="Solid" BorderColor="White" Width="95%" />
&nbsp&nbsp<asp:Label ID="pifIssueDate_Err" runat="server" Text="The value entered is not a date. Please use mm/dd/yyyy format." Font-Size="7pt" CssClass="lblValueRed" Visible="False" />
</asp:TableCell>
<asp:TableCell HorizontalAlign="Center">
<asp:CheckBox ID="ckbIssueDate" runat="server" Checked="false" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow VerticalAlign="Top">
<asp:TableCell>
&nbsp
<asp:TextBox ID="rhExpirationDate" runat="server" ReadOnly="True" Text="Expiration Date:" BorderStyle="Solid" BorderColor="White"
Font-Bold="True" Font-Size="8pt" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="tsExpirationDate" runat="server" Text="No Existing Value" ReadOnly="True" BorderStyle="Solid" BorderColor="White" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="pifExpirationDate" runat="server" Text="No Data Entered" BorderStyle="Solid" BorderColor="White" />
&nbsp&nbsp
<asp:Label ID="pifExpDate_Err" runat="server" Text="The value entered is not a date. Please use mm/dd/yyyy format." Font-Size="7pt" CssClass="lblValueRed" Visible="False" />
</asp:TableCell>
<asp:TableCell HorizontalAlign="Center">
<asp:CheckBox ID="ckbExpirationDate" runat="server" Checked="false" />
</asp:TableCell>
</asp:TableRow></asp:Table><table width="98%" cellpadding="20px" style="margin-top: 5px;margin-bottom: 3px" >
<tr valign="middle">
<td>
<asp:Label runat="server" ID="lblPassportUpdateMsg" Text="Unable to create or update this passenger's passport data."
CssClass="ErrorMessageRed" Width="100%" />
<asp:Label ID="lblNationality" runat="server" Text=" *Invalid Nationality " Font-Size="8pt" Visible="False" Font-Bold="True" ForeColor="Red" />
</td>
<td align="right">
<asp:Button ID="btnPassportUpdate" visible = "true" text="Update" CssClass="btnUpdate" runat="server" OnClientClick="Confirm()"/>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>

In your javascript, it looks like you are selecting the document id based of the text box value (textbox_id.Text)? Try selecting the client id property of the text box, then select the javascript text value. Something like this:
var ppn = document.getElementById("<%= pifPassportNbr.ClientID %>").value;
var pid = document.getElementById("<%= pifIssueDate.ClientID %>").value;
var pil = document.getElementById("<%= pifIssueLoc.ClientID %>").value;
var ped = document.getElementById("<%= pifExpirationDate.ClientID %>").value;

Related

Grid View Validation in asp.net for 2 grid View

In my code I have two Gridview. One is for adding Education Details and other for adding Experience details.
<asp:GridView runat="server" ID="gvDetails" CssClass="mydatagrid" HeaderStyle-CssClass="Grdheader" ShowFooter="true" AllowPaging="true" PageSize="10" AutoGenerateColumns="false" ShowHeaderWhenEmpty="true" OnRowDeleting="gvDetails_RowDeleting" OnSelectedIndexChanged="gvDetails_SelectedIndexChanged">
<HeaderStyle CssClass="headerstyle" />
<Columns>
<asp:BoundField DataField="rowid" HeaderText="No" ReadOnly="true" />
<asp:TemplateField HeaderText="Qualification">
<ItemTemplate>
<asp:TextBox ID="txtqualification" runat="server" Height="60px" Width="100%" BorderStyle="None" />
<asp:RequiredFieldValidator ID="rfvQualification" ControlToValidate="txtqualification" runat="server"
ErrorMessage="Required" ForeColor="Red"
ValidationGroup ="Group_"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "Specialization">
<ItemTemplate>
<asp:TextBox ID="txtspecialization" runat="server" Height="60px" Width="100%" BorderStyle="None" />
<asp:RequiredFieldValidator ID="rfvSpec" ControlToValidate="txtspecialization" runat="server"
ErrorMessage="Required" ForeColor="Red"
ValidationGroup ="Group_" ></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Board/University">
<ItemTemplate>
<asp:TextBox id="txtboard" runat="server" Height="60px" Width="100%" BorderStyle="None" />
<asp:RequiredFieldValidator ID="rfvBoard" ControlToValidate="txtboard" runat="server"
ErrorMessage="Required" ForeColor="Red"
ValidationGroup ="Group_"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Year">
<ItemTemplate>
<asp:TextBox id="txtyear" runat="server" onkeypress="CheckNumeric(event);" Height="60px" Width="100%" BorderStyle="None" />
<asp:RequiredFieldValidator ID="rfvYear" ControlToValidate="txtyear" runat="server"
ErrorMessage="Required" ForeColor="Red"
ValidationGroup ="Group_"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Percentage">
<ItemTemplate>
<asp:TextBox id="txtpercentage" runat="server" onkeypress="CheckNumeric(event);" Height="60px" Width="100%" BorderStyle="None" />
<asp:RequiredFieldValidator ID="rfvPerc" ControlToValidate="txtpercentage" runat="server"
ErrorMessage="Required" ForeColor="Red"
ValidationGroup ="Group_"></asp:RequiredFieldValidator>
</ItemTemplate>
<FooterTemplate >
<asp:Button ID="Button1" runat="server" Text="Add" ValidationGroup ="Group_" OnClick="gvDetails_SelectedIndexChanged" CssClass="grdadd"/>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField ShowDeleteButton="true" DeleteText="X" ControlStyle-CssClass="grdDelete"/>
</Columns>
<footerstyle CssClass="footerGrd"/>
</asp:GridView>
Above Grid for adding Education details.
<asp:GridView runat="server" ID="gvExperience" CssClass="mydatagrid" HeaderStyle-CssClass="Grdheader" ShowFooter="true" AllowPaging="true" PageSize="10" AutoGenerateColumns="false" ShowHeaderWhenEmpty="true" OnRowDeleting="gvExperience_RowDeleting" OnSelectedIndexChanged="gvExperience_SelectedIndexChanged">
<HeaderStyle CssClass="headerstyle" />
<Columns>
<asp:BoundField DataField="rowidE" HeaderText="No" ReadOnly="true" />
<asp:TemplateField HeaderText="Name of Organisation">
<ItemTemplate>
<asp:TextBox ID="txtOrganisation" runat="server" Height="60px" Width="100%" BorderStyle="None" />
<asp:RequiredFieldValidator ID="rfvorg" ControlToValidate="txtOrganisation" runat="server"
ErrorMessage="Required" ForeColor="Red"
ValidationGroup ="Group1_"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "Position held">
<ItemTemplate>
<asp:TextBox ID="txtposition" runat="server" Height="60px" Width="100%" BorderStyle="None" />
<asp:RequiredFieldValidator ID="rfvpos" ControlToValidate="txtposition" runat="server"
ErrorMessage="Required" ForeColor="Red"
ValidationGroup ="Group1_"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Nature of duty">
<ItemTemplate>
<asp:TextBox ID="txtNature" runat="server" Height="60px" Width="100%" BorderStyle="None" />
<asp:RequiredFieldValidator ID="rfvnature" ControlToValidate="txtNature" runat="server"
ErrorMessage="Required" ForeColor="Red"
ValidationGroup ="Group1_"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Duration From">
<ItemTemplate>
<asp:TextBox id="txtDuration" runat="server" Height="60px" Width="100%" BorderStyle="None" />
<asp:RequiredFieldValidator ID="rfduratin" ControlToValidate="txtDuration" runat="server"
ErrorMessage="Required" ForeColor="Red"
ValidationGroup ="Group1_"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Duration
To">
<ItemTemplate>
<asp:TextBox id="txtTo" runat="server" Height="60px" Width="100%" BorderStyle="None" />
<asp:RequiredFieldValidator ID="rfTo" ControlToValidate="txtTo" runat="server"
ErrorMessage="Required" ForeColor="Red"
ValidationGroup ="Group1_"></asp:RequiredFieldValidator>
</ItemTemplate>
<FooterTemplate >
<asp:Button ID="Button2" runat="server" ValidationGroup ="Group1_" Text="Add" OnClick="Button2_Click" CssClass="grdadd"/>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField ShowDeleteButton="true" DeleteText="X" ControlStyle-CssClass="grdDelete"/>
</Columns>
<footerstyle CssClass="footerGrd"/>
</asp:GridView>
I want validation to both grid. I used the required field for all the textbox in the grid but it validate the below grid also. In button click add i want to add a javascript for the validation

Confusion Getting this Errorr Unable to get property 'checked' of undefined or null reference

In Function when i use .checked then it stop working & generate below Error.
Currently im using Visual Studio 2015.Please Help
function GenderValidation(sender , e)
{
var male = document.getElementById('RadioButton_male').Checked;
var female = document.getElementById('RadioButton_female').Checked;
if (male == true || female == true)
{
e.IsValid = true;
} else {
e.IsValid = false;
}
}
**
0x800a138f - JavaScript runtime error: Unable to get property
'checked' of undefined or null reference
**
This is my Complete code
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="contactus.aspx.cs" Inherits="DVManagmentProject.contactus" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style type="text/css">
.auto-style1 {
width: 70%;
}
.auto-style2 {
width: 190px;
}
.auto-style3 {
width: 190px;
height: 34px;
}
.auto-style4 {
height: 34px;
}
.auto-style5 {
width: 190px;
height: 150px;
}
.auto-style6 {
height: 150px;
}
</style>
<script type="text/javascript" >
function GenderValidation(sender , e)
{
var male = document.getElementById('ContentPlaceHolder1_RadioButton_male').Checked;
var female = document.getElementById('ContentPlaceHolder1_RadioButton_female').Checked;
if (male == true || female == true)
{
e.IsValid = true;
} else {
e.IsValid = false;
}
}
function CustomValidatorAgremennt(sender, e)
{
var agreemenT = document.getElementById('ContentPlaceHolder1_CheckBox_agreement').Checked;
if(agreemenT==true)
{
e.IsValid = true;
}else
{
e.IsValid = false;
}
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h2>
This is Contact Us Page</h2>
<asp:ValidationSummary ID="contact_ValidationSummary" runat="server" BackColor="#FFFF99" ForeColor="Black" Font-Bold="true" Width="694px" BorderStyle="Double" />
<h3> Please Fill the Form Below:</h3>
<br />
<table class="auto-style1">
<tr>
<td class="auto-style2">Name:</td>
<td>
<asp:TextBox ID="name_TextBox" runat="server" Width="320px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator_name"
runat="server" Text="*"
ErrorMessage="Please Enter Your Name"
ForeColor="Red"
ControlToValidate="name_TextBox"
Display="Dynamic"
> </asp:RequiredFieldValidator>
<%-- <asp:RangeValidator ID="RangeValidator_name" runat="server"
ErrorMessage="*Text should between 10 to 30" MinimumValue="10" MaximumValue="30"
Type="Integer" ControlToValidate="name_TextBox"
Display="Dynamic"></asp:RangeValidator>--%>
</td>
</tr>
<tr>
<td class="auto-style3">Email:</td>
<td class="auto-style4">
<asp:TextBox ID="email_TextBox" runat="server" Width="320px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator_email"
runat="server"
SetFocusOnError="true"
Text="*"
ErrorMessage="Please Enter Your Email Name"
ControlToValidate="email_TextBox"
ForeColor="Red"
Display="Dynamic"> </asp:RequiredFieldValidator>
<asp:RegularExpressionValidator
ID="RegularExpressionValidator_email_TextBox"
runat="server"
ErrorMessage="Please Enter Correct Email Format"
Display="Dynamic"
ControlToValidate="email_TextBox"
ForeColor="Red"
SetFocusOnError="true"
Text="*"
ValidationExpression="\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*" > </asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="auto-style3">Re-Enter Email:</td>
<td class="auto-style4">
<asp:TextBox ID="TextBox_ReEmail" runat="server" Width="320px"></asp:TextBox>
<asp:CompareValidator
ID="CompareValidator_ReEmail_TextBox"
runat="server"
ErrorMessage="Email Must be Match"
Operator="Equal"
ControlToValidate="TextBox_ReEmail"
ControlToCompare="email_TextBox"
Type="String"
Display="Dynamic"
ForeColor="Red"
Font-Bold="true">*</asp:CompareValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator_ReEmail"
runat="server"
SetFocusOnError="true"
Text="*"
ErrorMessage="Please Confirm Your Email Name"
ControlToValidate="TextBox_ReEmail"
ForeColor="Red"
Display="Dynamic"> </asp:RequiredFieldValidator>
<asp:RegularExpressionValidator
ID="RegularExpressionValidator_ReEmail"
runat="server"
ErrorMessage="Please Enter Correct Re-Email Format"
Display="Dynamic"
ControlToValidate="TextBox_ReEmail"
ForeColor="Red"
SetFocusOnError="true"
Text="*"
ValidationExpression="\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*" ></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="auto-style3">Gender:</td>
<td class="auto-style4">
<asp:RadioButton ID="RadioButton_male" runat="server" Text="Male" GroupName="GenderGroup" />
<asp:RadioButton ID="RadioButton_female" runat="server" Text="Female" GroupName="GenderGroup" />
<asp:CustomValidator
ID="CustomValidator_genders"
runat="server"
ErrorMessage="Please Select Gender.!"
Font-Bold="True"
Display="Dynamic" ForeColor="Red" OnServerValidate="CustomValidator_genders_ServerValidate">*</asp:CustomValidator>
</td>
</tr>
<tr>
<td class="auto-style3">Age:</td>
<td class="auto-style4">
<asp:TextBox ID="Age_TextBox" runat="server" Width="318px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server"
SetFocusOnError="true"
Text="*"
ErrorMessage="Please Enter Your Age"
ControlToValidate="Age_TextBox"
ForeColor="Red"
Display="Dynamic"> </asp:RequiredFieldValidator>
<asp:RangeValidator
ID="RangeValidator_Age"
runat="server"
ErrorMessage="Age should between 18 to 99"
Type="Integer"
Display="Dynamic"
SetFocusOnError="true"
ControlToValidate="Age_TextBox"
MinimumValue="18"
MaximumValue="99"
></asp:RangeValidator>
</td>
</tr>
<tr>
<td class="auto-style2">Subject:</td>
<td>
<asp:DropDownList ID="subject_DropDownList" runat="server" Width="320px">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="auto-style5">Message </td>
<td class="auto-style6">
<asp:TextBox ID="message_TextBox" runat="server" Height="140px" TextMode="MultiLine" Width="320px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">Agreement:</td>
<td>
<asp:CheckBox ID="CheckBox_agreement" runat="server" Text="Please Select Our Terms And Conditions.!" />
<asp:CustomValidator
ID="CustomValidator_Agreement"
runat="server"
Display="Dynamic"
ErrorMessage="Please Check Terms and Conditions"
Font-Bold="True"
ForeColor="Red" OnServerValidate="CustomValidator_Agreement_ServerValidate">*</asp:CustomValidator>
</td>
</tr>
<tr>
<td class="auto-style2"> </td>
<td>
<asp:Button ID="submit_Button" runat="server" Font-Bold="True" Text="Submit" Width="320px" />
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
</table>
<p>
</p>
</asp:Content>
This is Debbuger Code
[1]: https://i.stack.imgur.com/PG8hC.jpg
[2]: https://i.stack.imgur.com/Jqw0X.jpg
[3]: https://i.stack.imgur.com/DuaNT.jpg
[4]: https://i.stack.imgur.com/DrTPP.jpg
[5]: https://i.stack.imgur.com/1Dhc1.jpg
[6]: https://i.stack.imgur.com/880dI.jpg
[7]: https://i.stack.imgur.com/DWQ7D.jpg
[8]: https://i.stack.imgur.com/LdHXg.jpg
[9]: https://i.stack.imgur.com/xVXI1.jpg
[10]: https://i.stack.imgur.com/qC4LA.jpg
Problem is Solved . I have Changed
ContentPlaceHolder1_RadioButton_male and
ContentPlaceHolder1_RadioButton_female
instead of
RadioButton_male and RadioButton_female
as well as in Javascript Function .i have changed (.Checked) in small (.checked) and it worked for me .

Identifying EmptyDataTemplate control in Jquery

I need to identify a control that I have in the EmptyDataTemplate of a GridView within a jquery function call.
In the code-behind, you can do this to get all of the controls:
Control tFooterControls = grid.Controls[0].Controls[0];
then a FindControl("") to get a specific control.
Is there an equivalent in jquery?
I can't use the ID because I use the same ID for the Gridview control as the EmptyDataTemplate to make the code-behind simpler.
This is my GridView markup:
<div id="DelegateGridWrapper">
<asp:GridView ID="DelegateInfoGridView" runat="server"
AutoGenerateColumns="false" Caption="Delegate Information"
CaptionAlign="Top" CssClass="grid" RowStyle-Wrap="true"
HorizontalAlign="Left" ShowFooter="true"
AllowPaging="true" PageSize="5" ShowHeaderWhenEmpty="false" onrowediting="DelegateInfoGridView_RowEditing"
onrowcancelingedit="DelegateInfoGridView_RowCancelingEdit" onrowdeleting="DelegateInfoGridView_RowDeleting"
onrowupdating="DelegateInfoGridView_RowUpdating"
ondatabound="DelegateInfoGridView_DataBound"
onrowcommand="DelegateInfoGridView_RowCommand">
<Columns>
<asp:TemplateField HeaderText="Recipient ID">
<ItemTemplate>
<asp:Label ID="deligvLblRecipientID" runat="server" Text='<%# Bind("RecipientID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Delegate" ItemStyle-Wrap="false">
<ItemTemplate>
<asp:Label ID="deligvLblRecipientName" runat="server" Text='<%# Bind("RecipientName") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="deligvDDLRecipientName" runat="server" ClientIDMode="Static"
data-placeholder="Choose delegate…" class="chosen-single">
</asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Active">
<ItemTemplate>
<asp:Label ID="deligvLblActive" runat="server" Text='<%# (Boolean.Parse(Eval("Active").ToString())) ? "Yes" : "No" %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="deligvDDLActive" runat="server" Text='<%# (Boolean.Parse(Eval("Active").ToString())) ? "Yes" : "No" %>'>
<asp:ListItem>Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="deligvDDLActiveInsert" runat="server">
<asp:ListItem Selected="True">Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Action" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Button ID="deligvEditButton" runat="server" CausesValidation="False" CommandName="Edit"
Text="Edit" CssClass="gridActionbutton">
</asp:Button>
<asp:Button ID="deligvDeleteButton" runat="server" CausesValidation="False" CommandName="Delete" ClientIDMode="Static"
Text="Delete" CssClass="gridActionbutton" OnClientClick="return confirm('Are you sure you want to delete this Delegate Information?')" >
</asp:Button>
</ItemTemplate>
<EditItemTemplate>
<asp:Button ID="deligvUpdateButton" runat="server" CausesValidation="False" CommandName="Update"
Text="Update" CssClass="gridActionbutton"></asp:Button>
<asp:Button ID="deligvCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel" CssClass="gridActionbutton"></asp:Button>
</EditItemTemplate>
<FooterTemplate>
<asp:Button ID="deligvAddButton" runat="server" CommandName="Add" Text="Add Delegate" Width="90%" CausesValidation="false"
CssClass="gridActionbutton">
</asp:Button>
</FooterTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<tr>
<th>Recipient ID</th>
<th>Delegate</th>
<th>Active</th>
<th>Action</th>
</tr>
<tr>
<td colspan="4" style="text-align:center;">
No Delegates were found for you. Delegates can be added by clicking the 'Add Delegate' Button.
</td>
</tr>
<tr>
<td></td>
<td>
<asp:DropDownList ID="deligvDDLRecipientName" runat="server" ClientIDMode="Static"
data-placeholder="Choose delegate…" class="chosen-single">
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="deligvDDLActiveInsert" runat="server">
<asp:ListItem Selected="True">Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:Button ID="deligvAddButtonEmpty" runat="server" CommandName="Add" Text="Add Delegate" Width="90%" CausesValidation="false"
CssClass="gridActionbutton">
</asp:Button>
</td>
</tr>
</EmptyDataTemplate>
</asp:GridView>
UPDATE
This is the code-behind that uses the same ID for the Gridview or the EmptyDataTemplate once it determines the row that it is coming from:
protected void DelegateInfoGridView_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
if (e.CommandName.Equals("Add"))
{
//Get the Footer Controls that have the data
Control tFooterControls = getFooterControls(DelegateInfoGridView);
//Get the data for each control
int tiDelegateID = Convert.ToInt32((tFooterControls.FindControl("deligvDDLRecipientName") as DropDownList).SelectedValue);
bool tbIsActive = convertIsActiveValue((tFooterControls.FindControl("deligvDDLActiveInsert") as DropDownList).SelectedValue);
m_strUserID = CommonMethods.ParseUserID(User.Identity.Name);
//Insert into database
m_pagingClient.InsertDelegateInformation(m_strUserID, tiDelegateID, tbIsActive);
//Refresh the grid
populateDelegateInfoGrid();
}
}
catch (Exception ex)
{
//TO DO: Response.Redirect("~/Error.aspx");
}
}
UPDATE
I was able to get the IDs of the elements using the jquery below. However, it still does not solve my problem of updating the dropdowns.
$("input[id$=deligvDeleteButton]").click(function () {
$("[id*='deligvDDLRecipientName']").each(function () {
alert($(this).attr('id'));
$(this).val("").trigger("chosen:updated");
});
});
I was able to get the IDs of the elements using the jquery below. However, it still does not solve my problem of updating the dropdowns.
$("input[id$=deligvDeleteButton]").click(function () {
$("[id*='deligvDDLRecipientName']").each(function () {
alert($(this).attr('id'));
$(this).val("").trigger("chosen:updated");
});
});

control inside a repeater

I have a repeater control in my aspx page which has a textbox field called "name" and a hidden field called "id" that is the id of the name.
I want to get the value of the id field when the name textbox is in focus and pass it, can you please let me know how i can accomplish that?
<asp:Repeater ID="rpt" runat="server">
<ItemTemplate>
<tr>
<td >
<asp:TextBox ID="txtName" runat="server" Text='<%#Eval("Name")%>'/>
</td>
<td >
<asp:DropDownList ID="ddListNumber" runat="server">
<asp:ListItem Text='First' Value="1" />
<asp:ListItem Text='Second' Value="0" />
</asp:DropDownList>
</td>
<asp:HiddenField runat="server" Value='<%# Eval("ID") %>' ID="txtID" Visible="false" />
</tr>
</ItemTemplate>
</asp:Repeater>

I want to display some data in the popup (popup should not be the ajax control). I was trying to do it by placing a grid within grid

I have a gridview and I want to display some data in the popup (popup should not be the ajax control).I was trying to do it by placing a gridview within gridview like:
<asp:GridView ID="grdInspectionApprovel" runat="server" Width="99%" EmptyDataText="<%$ Resources:Captions,grdEmptyPeriods%>"
AutoGenerateColumns="False" ShowFooter="true" Style="margin-bottom: 1px" CssClass="grdviewbrd"
OnRowDataBound="grdInspectionApprovel_RowDataBound" OnRowCommand="grdInspectionApprovel_RowCommand"
OnRowCreated="grdInspectionApprovel_RowCreated" OnRowEditing="grdInspectionApprovel_RowEditing">
<RowStyle CssClass="RowStyle" />
<EmptyDataRowStyle CssClass="emptyRow1" />
<PagerSettings Visible="false" />
<AlternatingRowStyle CssClass="AtlernatingRowStyle" />
<Columns>
<asp:TemplateField HeaderText="POPUP" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<div id="simplediv" style="background-color: White; border: 1px solid black; display: none;
width: 70%; height: 200px;">
<table width="100%">
<tr>
<td align="right">
<input type="image" src="~/App_Themes/MyWebTheme/images/imgError.gif" id="imageButton"
onclick="Popup.hide('simplediv');return false;" />
</td>
</tr>
<tr>
<td>
<asp:GridView ID="grdInspectionApprovelPOPUP" runat="server" Width="98%" EmptyDataText="<%$ Resources:Captions,grdEmptyPeriods%>"
AutoGenerateColumns="False" ShowFooter="true" Style="margin-bottom: 1px" CssClass="grdviewbrd">
<RowStyle CssClass="RowStyle" />
<EmptyDataRowStyle CssClass="emptyRow1" />
<PagerSettings Visible="false" />
<AlternatingRowStyle CssClass="AtlernatingRowStyle" />
<Columns>
<asp:TemplateField HeaderText="<%$ Resources:Captions,lblSupplierSINo%>" ItemStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:TextBox ID="txtSupplierSINo" runat="server" Text='<%# Eval("SupplierSerialNo") %>'
Width="150px"></asp:TextBox>
<headerstyle cssclass="gridtophead" />
<itemstyle horizontalalign="Center"></itemstyle>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle CssClass="grid_title" />
</asp:GridView>
</td>
</tr>
<tr>
<td>
<asp:ImageButton runat="server" ID="deletebtn1" CommandName="btnSave" ImageUrl="<%$ Resources:Paths,imgBtnSave%>" />
<asp:LinkButton runat="server" ID="deletebtn" CommandName="btnSave" Text="Save"></asp:LinkButton>
<asp:Button ID="Button1" runat="server" Text="<%$ Resources:Captions,btnReset%>"
CssClass="btnStyle" />
</td>
</tr>
</table>
</div>
+
<asp:LinkButton runat="server" ID="linkbtnPopup" CommandName="callPopup" Text="++"
CommandArgument='<%# Eval("WOID") %>'></asp:LinkButton>
</ItemTemplate>
<FooterStyle HorizontalAlign="Center"></FooterStyle>
<HeaderStyle CssClass="gridtophead" />
<ItemStyle HorizontalAlign="Right" Width="2%"></ItemStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="<%$ Resources:Captions,lblSrNo%>" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lblWO" Text='<%# Eval("WOID") %>' runat="server" Style="display: none;"></asp:Label>
<asp:Label ID="lblAssetID" Text='<%# Eval("AssetID") %>' runat="server" Style="display: none;"></asp:Label>
<%#(Convert.ToInt32(hfPageIndex.Value) * grdInspectionApprovel.PageSize) + Container.DataItemIndex + 1%>
</ItemTemplate>
<FooterStyle HorizontalAlign="Center"></FooterStyle>
<HeaderStyle CssClass="gridtophead" />
<ItemStyle HorizontalAlign="Right" Width="2%"></ItemStyle>
</asp:TemplateField>
</Columns>
<HeaderStyle CssClass="grid_title" />
</asp:GridView>
and Popup.show('simplediv') this function is from javascript file. I want to bind the chield gridview on each rowCommand of parent gridview and want to display this gridview on popup div.

Categories