ASP WebForms AutoCompleteExtender in GridView not firing - asp.net

I have this webform with 3 AutoCompleteExtenders using the AjaxControlToolkit. The first one deals with customers from a database and that works very well. I have place 2 others in a gridview, AutoCompleteExtenders 2 and 3 to fetch items. For some reason, these do not work and a breakpoint in Items.asmx does not reach when running the code. I have setup these 2 extenders same as the customer one.
What am I doing wrong? I have searched articles online on use in gridviews but am unable to find the issue.
I have
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
in the masterpage.
Code in webform:
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="PipemanWebPortal.Views.PurchaseOrders.Default" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h2>Add Purchase Order</h2>
<script type="text/javascript">
$(document).ready(function () {
window.setTimeout(function () {
$(".alert").fadeTo(1500, 0).slideUp(500, function () {
$(this).remove();
});
}, 3000);
});
// On Page Load
$(function () {
SetDatePicker();
});
// On UpdatePanel Refresh
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (prm != null) {
prm.add_endRequest(function (sender, e) {
if (sender._postBackSettings.panelsToUpdate != null) {
SetDatePicker();
$(".datepicker-orient-bottom").hide();
}
});
};
function SetDatePicker() {
$('#datetimepicker').datepicker
({
format: 'dd.MM.yyyy',
inline: true,
todayHighlight: true,
autoclose: true
});
}
</script>
<div runat="server" visible="false" id="AlertDanger" class="alert alert-danger">
×
<strong>You must choose a date</strong>
</div>
<div runat="server" visible="false" id="AlertSuccess" class="alert alert-success">
×
<strong>Purchase requisition saved successfully</strong>
</div>
<asp:Panel ID="PODetails" runat="server">
<div>
<asp:UpdatePanel ID="UpdatePanelPO" runat="server">
<ContentTemplate>
<asp:Panel ID="Panel1" runat="server" BackColor="#E6E6E6">
<fieldset class="form-horizontal">
<div class="row">
<div class="form-group col-sm-6">
<asp:Label runat="server" CssClass="col-sm-6 control-label">Required Date</asp:Label>
<div class="col-sm-6">
<div class="input-group date" id="datetimepicker">
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
<asp:TextBox ID="txtRequiredDate" runat="server" CssClass="form-control"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtRequiredDate" Display="Dynamic"
CssClass="text-danger" ErrorMessage="The Required Date field is required." />
</div>
</div>
</div>
<div class="form-group col-sm-6">
<asp:Label runat="server" CssClass="col-sm-6 control-label">No.</asp:Label>
<div class="col-sm-6">
<asp:Label ID="lblDocNum" runat="server" CssClass="form-control"></asp:Label>
</div>
</div>
</div>
</fieldset>
<fieldset class="form-horizontal">
<div class="row">
<div class="form-group col-sm-6">
<asp:Label runat="server" CssClass="col-sm-6 control-label" class="">Cust. PO No.</asp:Label>
<div class="col-sm-6">
<div class="input-group">
<asp:TextBox ID="txtPurchaseOrderNo" runat="server" CssClass="form-control"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtPurchaseOrderNo" Display="Dynamic"
CssClass="text-danger" ErrorMessage="The Cust. Purchase Order No field is required." />
</div>
</div>
</div>
<div class="form-group col-sm-6">
<asp:Label runat="server" CssClass="col-sm-6 control-label">Contact</asp:Label>
<div class="col-sm-6">
<div class="input-group">
<asp:TextBox ID="txtContact" runat="server" CssClass="form-control"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtContact" Display="Dynamic"
CssClass="text-danger" ErrorMessage="The Contact field is required." />
</div>
</div>
</div>
</div>
</fieldset>
<fieldset class="form-horizontal">
<div class="row">
<div class="form-group col-sm-3">
<asp:Label runat="server" CssClass="col-sm-12 control-label" class="">Customer Name</asp:Label>
</div>
<div class="form-group col-sm-9">
<asp:TextBox ID="txtCustomer" runat="server" CssClass="form-control"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender
ID="AutoCompleteExtender1"
runat="server"
TargetControlID="txtCustomer"
ServicePath="../../Web_Service/Customers.asmx"
ServiceMethod="GetCustomers"
MinimumPrefixLength="2"
EnableCaching="true"
CompletionSetCount="10"
CompletionInterval="10"
DelimiterCharacters=";, :"
ShowOnlyCurrentWordInCompletionListItem="true">
</ajaxToolkit:AutoCompleteExtender>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtCustomer" Display="Dynamic"
CssClass="text-danger" ErrorMessage="The Customer field is required." />
</div>
</div>
</div>
</fieldset>
</asp:Panel>
<asp:GridView ID="pOGridView"
runat="server"
AutoGenerateColumns="False"
AllowPaging="True"
AllowSorting="True"
ShowFooter="True"
OnRowEditing="pOGridView_RowEditing"
OnRowUpdating="pOGridView_RowUpdating"
OnPageIndexChanging="pOGridView_PageIndexChanging"
OnRowCancelingEdit="pOGridView_RowCancelingEdit"
PagerStyle-CssClass="bs-pagination"
ShowHeaderWhenEmpty="True"
EmptyDataText="No Records Found"
CssClass="table table-striped table-bordered table-hover table-condensed">
<Columns>
<asp:TemplateField ItemStyle-Width="30px" HeaderText="#">
<ItemTemplate>
<asp:Label ID="lblLineNum" Text='<%# Container.DataItemIndex + 1 %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="120px" HeaderText="Item">
<ItemTemplate>
<asp:Label ID="lblItem" runat="server"
Text='<%# Bind("Item")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtItem" runat="server" Width="300px" Text='<%# Bind("Item")%>'></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender
ID="AutoCompleteExtender2"
runat="server"
TargetControlID="txtItem"
ServicePath="../../Web_Service/Items.asmx"
ServiceMethod="GetItems"
MinimumPrefixLength="2"
EnableCaching="true"
CompletionSetCount="10"
CompletionInterval="10"
DelimiterCharacters=";, :"
ShowOnlyCurrentWordInCompletionListItem="true">
</ajaxToolkit:AutoCompleteExtender>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtItem" Display="Dynamic" ValidationGroup="Edit"
CssClass="text-danger" ErrorMessage="The Item field is required." />
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtItem" runat="server" Width="300px"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender
ID="AutoCompleteExtender3"
runat="server"
TargetControlID="txtItem"
ServicePath="../../Web_Service/Items.asmx"
ServiceMethod="GetItems"
MinimumPrefixLength="2"
EnableCaching="true"
CompletionSetCount="10"
CompletionInterval="10"
DelimiterCharacters=";, :"
ShowOnlyCurrentWordInCompletionListItem="true">
</ajaxToolkit:AutoCompleteExtender>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtItem" Display="Dynamic" ValidationGroup="Insert"
CssClass="text-danger" InitialValue="-1" ErrorMessage="The Item field is required." />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="60px" HeaderText="Qty.">
<ItemTemplate>
<asp:Label ID="lblQuantity" runat="server"
Text='<%# Bind("Quantity")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtQuantity" runat="server" Width="100px"
Text='<%# Bind("Quantity")%>'></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtQuantity" Display="Dynamic" ValidationGroup="Edit"
CssClass="text-danger" ErrorMessage="The Quantity field is required." />
<asp:RegularExpressionValidator ControlToValidate="txtQuantity" runat="server" CssClass="text-danger" Display="Dynamic"
ErrorMessage="Only integers allowed." ValidationExpression="^(0|[1-9]\d*)$"
ValidationGroup="Edit"></asp:RegularExpressionValidator>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtQuantity" runat="server" Width="100px"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtQuantity" Display="Dynamic" ValidationGroup="Insert"
CssClass="text-danger" ErrorMessage="The Quantity field is required." />
<asp:RegularExpressionValidator ControlToValidate="txtQuantity" runat="server" CssClass="text-danger" Display="Dynamic"
ErrorMessage="Only integers allowed." ValidationExpression="^(0|[1-9]\d*)$"
ValidationGroup="Insert"></asp:RegularExpressionValidator>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="80px" HeaderText="Unit Price">
<ItemTemplate>
<asp:Label ID="lblUnitPrice" runat="server"
Text='<%# Bind("UnitPrice")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtUnitPrice" runat="server" Width="100px"
Text='<%# Bind("UnitPrice")%>'></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtUnitPrice" Display="Dynamic" ValidationGroup="Edit"
CssClass="text-danger" ErrorMessage="The Unit Price is required." />
<asp:RegularExpressionValidator ControlToValidate="txtUnitPrice" runat="server" CssClass="text-danger" Display="Dynamic"
ErrorMessage="Only numbers allowed." ValidationExpression="^[0-9]{0,6}(\.[0-9]{1,2})?$"
ValidationGroup="Edit"></asp:RegularExpressionValidator>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtUnitPrice" runat="server" Width="100px"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtUnitPrice" Display="Dynamic" ValidationGroup="Insert"
CssClass="text-danger" ErrorMessage="The Unit Price is required." />
<asp:RegularExpressionValidator ControlToValidate="txtUnitPrice" runat="server" CssClass="text-danger" Display="Dynamic"
ErrorMessage="Only numbers allowed." ValidationExpression="^[0-9]{0,6}(\.[0-9]{1,2})?$"
ValidationGroup="Insert"></asp:RegularExpressionValidator>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="80px" HeaderText="Order Price">
<ItemTemplate>
<asp:Label ID="lblOrderPrice" runat="server"
Text='<%# Bind("OrderPrice")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtOrderPrice" runat="server" Width="100px"
Text='<%# Bind("OrderPrice")%>'></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtOrderPrice" Display="Dynamic" ValidationGroup="Edit"
CssClass="text-danger" ErrorMessage="The Order Price is required." />
<asp:RegularExpressionValidator ControlToValidate="txtOrderPrice" runat="server" CssClass="text-danger" Display="Dynamic"
ErrorMessage="Only numbers allowed." ValidationExpression="^[0-9]{0,6}(\.[0-9]{1,2})?$"
ValidationGroup="Edit"></asp:RegularExpressionValidator>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtOrderPrice" runat="server" Width="100px"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtUnitPrice" Display="Dynamic" ValidationGroup="Insert"
CssClass="text-danger" ErrorMessage="The Order Price is required." />
<asp:RegularExpressionValidator ControlToValidate="txtOrderPrice" runat="server" CssClass="text-danger" Display="Dynamic"
ErrorMessage="Only numbers allowed." ValidationExpression="^[0-9]{0,6}(\.[0-9]{1,2})?$"
ValidationGroup="Insert"></asp:RegularExpressionValidator>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" ValidationGroup="Edit" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkRemove" runat="server"
CommandArgument='<%# Bind("LineNum")%>'
OnClientClick="return confirm('Are you sure you want to delete this row?')"
Text="Delete" OnClick="DeleteRowPurchaseOrder"></asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
<asp:Button ID="btnAdd" runat="server" Text="Add" ValidationGroup="Insert" CssClass="btn btn-primary btn-sm"
OnClick="AddRowPurchaseOrder" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<div class="form-group">
<div class="row">
<div class="col-sm-3">
<asp:Button runat="server" ID="InsertButton" OnClick="Insert" Text="Insert" CssClass="btn btn-block btn-primary" />
</div>
<div class="col-sm-3">
<asp:Button runat="server" ID="CancelButton" OnClick="Cancel" Text="Cancel" CausesValidation="false" CssClass="btn btn-block btn-default" />
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Panel>
</asp:Content>

Looks like the other two AutoCompleteExtender are on two different <asp:Panel>, try put on same Panel,
<asp:Panel ID="Panel1" runat="server" BackColor="#E6E6E6">. that's probably the reason why the first one is working, and other two are not.

Related

Data not inserting into database, it shows empty columns in table

I have form inside panel and I am inserting data into the database by using a stored procedure from form. It doesn't throw any error, but it is not showing data in the database. Code works successfully but columns in tables are empty.
This is my stored procedure:
CREATE procedure [dbo].[spDREG]
(#pname varchar(250),
#spname varchar(250),
#age int,
#spage int,
#cat varchar(50),
#mno bigint,
#emlid varchar(250),
#years varchar(50)
)
AS
BEGIN
DECLARE #dregid INT = ##identity
INSERT INTO DREG(P_NAME, SECP_NAME, AGE, AGET, CAT, MOB_NO, EMAILD, YEARS)
VALUES(#pname, #spname, #age, #spage, #cat, #mno, #emlid, #years)
END
This is my code behind
protected void Dsbtn_click(object sender, EventArgs e)
{
string psname ="spDREG"; ;
con.Open();
SqlCommand cmd = new SqlCommand(psname,con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("#pname", TextBox1.Text.ToString());
cmd.Parameters.AddWithValue("#spname", TextBox2.Text.ToString());
cmd.Parameters.AddWithValue("#age", TextBox22.Text.ToString());
cmd.Parameters.AddWithValue("#spage", TextBox24.Text.ToString());
cmd.Parameters.AddWithValue("#cat", DropDownList1.Text.ToString());
cmd.Parameters.AddWithValue("#mno", TextBox4.Text.ToString());
cmd.Parameters.AddWithValue("#emlid", TextBox5.Text.ToString());
cmd.Parameters.AddWithValue("#years", DropDownList2.Text.ToString());
cmd.ExecuteNonQuery();
con.Close();
dreglbl.Text = "You have successfully registered";
}
This is my design part
<asp:Panel runat="server" ID="dan" class="npan" Width="900px" Height="500px">
<h3 style="text-align: center" class="panhed">Please Fill This Form TO Participate(Dance Registration)</h3>
<div id="snam" runat="server" class="nam">
<asp:Label ID="Label2" runat="server" Text="Name of participant:"></asp:Label>
<asp:TextBox ID="TextBox1" CssClass="txtcls" runat="server" TextMode="MultiLine"></asp:TextBox>
<asp:Button ID="addm" class="addbtn" runat="server" autopostback="true" Text="Add member" OnClick="addm_Click" />
</div>
<div id="Div3" runat="server" class="nams">
<asp:Label ID="Label3" runat="server" autopostback="true" Text="Name of 2nd participant:"></asp:Label>
<asp:TextBox ID="TextBox2" CssClass="txtscls" runat="server"></asp:TextBox>
</div>
<div id="Div29" runat="server" class="nams">
<asp:Label ID="Label27" runat="server" Text="Age:"></asp:Label>
<asp:TextBox ID="TextBox22" CssClass="agtxt" placeholder="1st" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox24" CssClass="agstxt" placeholder="2nd" AutoPostBack="true" runat="server"></asp:TextBox>
</div>
<div id="Div2" runat="server" class="cate">
<asp:Label ID="Label4" runat="server" Text="Select Category:"></asp:Label>
<asp:DropDownList runat="server" ID="DropDownList1" Class="drpd" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Value="22">select</asp:ListItem>
<asp:ListItem Value="Ss">Solo</asp:ListItem>
<asp:ListItem Value="Dd">Duet</asp:ListItem>
<asp:ListItem Value="Gg">Group</asp:ListItem>
</asp:DropDownList>
</div>
<div id="divv" class="mobn" runat="server">
<asp:Label ID="Label5" runat="server" Text="Mobile No:"></asp:Label>
<asp:TextBox ID="TextBox4" CssClass="mobtxt" runat="server"></asp:TextBox>
</div>
<div id="Div6" runat="server" class="eml">
<asp:Label ID="Label6" runat="server" Text="E-Mail:"></asp:Label>
<asp:TextBox ID="TextBox5" CssClass="emtxt" runat="server"></asp:TextBox>
</div>
<div id="Div7" runat="server" class="yer">
<asp:Label ID="Label7" runat="server" Text="Select Year:"></asp:Label>
<asp:DropDownList runat="server" ID="DropDownList2" Class="drpds">
<asp:ListItem>select</asp:ListItem>
<asp:ListItem>First</asp:ListItem>
<asp:ListItem>Second</asp:ListItem>
<asp:ListItem>Third</asp:ListItem>
<asp:ListItem>other</asp:ListItem>
</asp:DropDownList>
</div>
<div id="Div8" runat="server" class="btndiv">
<asp:Button ID="Dsbtn" runat="server" Class="Btncss" Text="Submit" OnClick="Dsbtn_click" />
<asp:Label ID="dreglbl" runat="server" Text="label"></asp:Label>
</div>
</asp:Panel>
Please solve it guys. Thank you

asp:RadioButtonList asp:RequiredFieldValidator Never fires the validation

I have a webforms page (don't ask) that I am trying to get some client side validation working on, using the standard validators.
Heres some partial code
<asp:TemplateField ItemStyle-Width="50px" HeaderText="Received">
<HeaderStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:RadioButtonList ID="rbIsRecv" RepeatDirection="Horizontal"
runat="server" ValidationGroup="Curriculum">
<asp:ListItem Value="1">Yes </asp:ListItem>
<asp:ListItem Value="0">No</asp:ListItem>
</asp:RadioButtonList>
<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1"
ControlToValidate="rbIsRecv" Text="Required"
ValidationGroup="Curriculum" />
</ItemTemplate>
</asp:TemplateField>
<.......>
<asp:TemplateField ItemStyle-Width="50px" HeaderText="Actually Received">
<HeaderStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:TextBox ID="txtActual" runat="server" />
<asp:RequiredFieldValidator ForeColor="Red" ValidationGroup="AllValidators" runat="server"
ControlToValidate="txtActual" ErrorMessage="All values must be filled in!" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</div>
</div>
<div class="row pull-right">
<asp:Label runat="server">Employee ID: </asp:Label>
<asp:TextBox ID="txtName" runat="server" /><br />
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" CssClass="btn-primary pull-right" />
</div>
<div class="row">
<asp:RequiredFieldValidator ForeColor="Red" ValidationGroup="AllValidators" runat="server" ControlToValidate="txtName" ErrorMessage="Please enter your employee Number!" />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="AllValidators"/>
</div>
So when I submit it throws and error to the Summary Control from the txtName control properly, but none of the controls within the grids....
Any ideas?
You cannot validate a RadioButtonList with a RequiredFieldValidator. You need a CustomValidator for that.
<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Select an option"
ClientValidationFunction="validateRadioButtonList"></asp:CustomValidator>
<script type="text/javascript">
function validateRadioButtonList(oSrc, args) {
if ($("input[name='<%= RadioButtonList1.UniqueID %>']:checked").val() == null) {
args.IsValid = false;
} else {
args.IsValid = true;
}
}
</script>

how to dynamically assign id to controls - controls are inside datalist in asp .net

I am using datalist for showing datas. Datas are test questions with 4 options.I have 50 questions displaying in datalist.
By using ItemDataBound event - i am making visible only one question with 4 options to user. Remaining questions are invisible . In the Itemdatabound event - i am assigning id to the radio buttons. but also id is not assigned to the datalist ,it showing different id.
<div class="widget">
<div class="widget-header" align="center" style="background: #4a98c9; color: #FFFFFF;">
<h4>
<asp:Label ID="Label5" runat="server" Text="Question : "></asp:Label>
<asp:Label ID="lblQuestionNo" runat="server" Text="0 of 0"></asp:Label></h4>
<asp:HiddenField ID="HdCurrentQuestSlNo" runat="server" />
<asp:HiddenField ID="HdfMinTime" runat="server" />
<asp:HiddenField ID="HdfSecTime" runat="server" />
<asp:HiddenField ID="HiddenField1" runat="server" />
<asp:HiddenField ID="HdfQSlNo" runat="server" />
<asp:HiddenField ID="HdQuestCount" runat="server" Value="0"/>
</div>
<div class="widget-content">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="PanelQuestBlock" runat="server" ScrollBars="Vertical" Width="100%" Height="325px">
<asp:DataList runat="server" ID="DataListQuestion"
onitemdatabound="DataListQuestion_ItemDataBound"
onitemcreated="DataListQuestion_ItemCreated">
<ItemTemplate>
<div class="questdisplayId" id="divQuestBlock" runat="server">
<div>
<asp:HiddenField ID='HdSlNo' runat="server" Value='<%# Eval("SlNo") %>' ClientIDMode="Static"/>
<asp:HiddenField ID="HdUserQuestId" runat="server" Value='<%# Eval("UserQuestionId") %>' ClientIDMode="Static"/>
<asp:HiddenField ID="HdTotalOptions" runat="server" Value='<%# Eval("TotalOptions") %>' ClientIDMode="Static"/>
<asp:HiddenField ID="HdQuestAnsweredTimeSecs" runat="server" Value='<%# Eval("AnsweredTimeSecs") %>' ClientIDMode="Static"/>
<asp:HiddenField ID="HdOptionAnswered" runat="server" Value='<%# Eval("OptionAnswered") %>' ClientIDMode="Static"/>
</div>
<div>
<asp:Label ID="Question" runat="server" Text='<%# Eval("Question") %>'></asp:Label>
</div>
<div class="answer-row" id="divOption1" runat="server">
<asp:RadioButton ID="Option1" runat="server" GroupName="Answer" value="1" Text='<%# Eval("Option1") %>'
CssClass="rdbtn" Style="vertical-align: middle" ClientIDMode="Static"/>
<asp:Label ID="lblOpt1" runat="server" Text=""></asp:Label>
</div>
<div class="answer-row" id="divOption2" runat="server">
<asp:RadioButton ID="Option2" runat="server" GroupName="Answer" value="2" Text='<%# Eval("Option2") %>'
CssClass="rdbtn" Style="vertical-align: middle" ClientIDMode="Static"/>
<asp:Label ID="lblOpt2" runat="server" Text=""></asp:Label>
</div>
<div class="answer-row" id="divOption3" runat="server">
<asp:RadioButton ID="Option3" runat="server" GroupName="Answer" value="3" Text='<%# Eval("Option3") %>'
CssClass="rdbtn" Style="vertical-align: top; left: auto;" ClientIDMode="Static"/>
<asp:Label ID="lblOpt3" runat="server" Text=""></asp:Label>
</div>
<div class="answer-row" id="divOption4" runat="server">
<asp:RadioButton ID="Option4" runat="server" GroupName="Answer" value="4" Text='<%# Eval("Option4") %>'
CssClass="rdbtn" Style="vertical-align: text-top" ClientIDMode="Static"/>
<asp:Label ID="lblOpt4" runat="server" Text=""></asp:Label>
</div>
<div class="answer-row" id="divOption5" runat="server">
<asp:RadioButton ID="Option5" runat="server" GroupName="Answer" value="4" Text='<%# Eval("Option5") %>'
CssClass="rdbtn" Style="vertical-align: text-top" ClientIDMode="Static"/>
<asp:Label ID="lblOpt5" runat="server" Text=""></asp:Label>
</div>
</div>
</ItemTemplate>
</asp:DataList>
</asp:Panel>
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<div class="row">
<div class="span8" align="center">
<asp:Button ID="btnClear" runat="server" Text="Clear Selection"
CssClass="btn btn-warning" OnClientClick="Clearbutton();"
/>
<asp:Button ID="btnSave" runat="server" Text="Save & Next" CssClass="btn btn-success" OnClientClick="Savebutton()"/>
</div>
<div class="span4" align="center">
<asp:Button ID="btnReview" runat="server" Text="Mark Review & Next" CssClass="btn btn-info" OnClientClick="Reviewbutton()"/>
<asp:Button ID="btnFinish" runat="server" Text="Finish" CssClass="btn btn-danger" OnClientClick="Finishbutton()"/>
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnReview" />
<asp:AsyncPostBackTrigger ControlID="btnClear" />
<asp:AsyncPostBackTrigger ControlID="btnSave" />
</Triggers>
</asp:UpdatePanel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DataListQuestion" />
</Triggers>
</asp:UpdatePanel>
</div>
</div>
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
HiddenField HdSlNo = (HiddenField)e.Item.FindControl("HdSlNo");
RadioButton Option1 = (RadioButton)e.Item.FindControl("Option1");
RadioButton Option2 = (RadioButton)e.Item.FindControl("Option2");
RadioButton Option3 = (RadioButton)e.Item.FindControl("Option3");
RadioButton Option4 = (RadioButton)e.Item.FindControl("Option4");
RadioButton Option5 = (RadioButton)e.Item.FindControl("Option5");
Option1.ID = "rdbtnoption1_" + HdSlNo.Value.ToString();
Option2.ID = "rdbtnoption2_" + HdSlNo.Value.ToString();
Option3.ID = "rdbtnoption3_" + HdSlNo.Value.ToString();
Option4.ID = "rdbtnoption4_" + HdSlNo.Value.ToString();
Option5.ID = "rdbtnoption5_" + HdSlNo.Value.ToString();
}
In my design page code , using Datalist i am binding 50 questions . while binding itself i am hiding 2 to 50 questions . Question 1 only visible. I tried to give dynamic id for every questions and options using event databound and rowcreated. First it got error , after that i changed properties as ClientIDMode="Static" for controls.it shown different id. But if i click any button event again it clear the id's.again it shows old ids only.

ValidationSummary always showing asterisks

I have the following setup for a changepassword control:
<asp:ChangePassword ID="ChangePassword1" runat="server">
<ChangePasswordTemplate>
<h3>
Password Management</h3>
<asp:TextBox ID="CurrentPassword" runat="server" TextMode="Password" Style="display: none;"></asp:TextBox>
<div class="field">
<asp:Label ID="NewPasswordLabel" runat="server" AssociatedControlID="NewPassword">New Password:</asp:Label>
<asp:TextBox ID="NewPassword" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="NewPasswordRequired" runat="server" ControlToValidate="NewPassword" Display="Dynamic"
ErrorMessage="New Password" ToolTip="New Password is required."
ValidationGroup="ChangePassword1" EnableClientScript="false"></asp:RequiredFieldValidator>
</div>
<div class="field">
<asp:Label ID="ConfirmNewPasswordLabel" runat="server" AssociatedControlID="ConfirmNewPassword">Confirm New Password:</asp:Label>
<asp:TextBox ID="ConfirmNewPassword" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="ConfirmNewPasswordRequired" runat="server" ControlToValidate="ConfirmNewPassword"
ErrorMessage="Confirm New Password" ToolTip="Confirm New Password is required." Display="Dynamic"
ValidationGroup="ChangePassword1" EnableClientScript="false"></asp:RequiredFieldValidator>
</div>
<div class="field">
<asp:CompareValidator ID="NewPasswordCompare" runat="server" ControlToCompare="NewPassword"
ControlToValidate="ConfirmNewPassword" Display="Dynamic" ErrorMessage="The Confirm New Password must match the New Password entry."
ValidationGroup="ChangePassword1"></asp:CompareValidator>
</div>
<asp:ValidationSummary ID="ChangeUserPasswordValidationSummary" runat="server" CssClass="failureNotification"
ValidationGroup="ChangePassword1"/>
<div class="action">
<asp:Button ID="ChangePasswordPushButton" runat="server" CommandName="ChangePassword"
Text="Change Password" ValidationGroup="ChangePassword1" />
<asp:Button ID="CancelPushButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel" Width="120" />
</div>
</ChangePasswordTemplate>
</asp:ChangePassword>
When i click on the ChangePasswordPushButton the validation all works as expected other than the validationsummary shows 2 asterisks!
Anyone have any idea why
I found out what the problem was. Error message was being set in a Theme!
Grrr
Try adding the following code on all of your validators and the ValidationSummary:
EnableTheming="False"

Why is my MaskedEditValidator is not working?

I have following controls in my page, my CompareValidator works, but not the MaskedEditValidator. Am I missing anything?
<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<div>
Date: <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:CalendarExtender ID="TextBox1_CalendarExtender" runat="server"
Enabled="True" TargetControlID="TextBox1">
</asp:CalendarExtender>
<asp:MaskedEditExtender ID="TextBox1_MaskedEditExtender" runat="server"
CultureAMPMPlaceholder="" CultureCurrencySymbolPlaceholder=""
CultureDateFormat="" CultureDatePlaceholder="" CultureDecimalPlaceholder=""
CultureThousandsPlaceholder="" CultureTimePlaceholder="" Enabled="True"
TargetControlID="TextBox1" Mask="99/99/9999" MaskType="Date">
</asp:MaskedEditExtender>
<%--<asp:MaskedEditValidator ID="MaskedEditValidator1" runat="server"
ControlExtender="TextBox1_MaskedEditExtender" ControlToValidate="TextBox1"
ErrorMessage="The Date is not valid!" IsValidEmpty="False">
</asp:MaskedEditValidator>--%>
<asp:CompareValidator ID="CompareValidator1" runat="server"
ErrorMessage="Invalid Date!" ControlToValidate="TextBox1"
Operator="DataTypeCheck" Type="Date">
</asp:CompareValidator>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="PostBack"
onclick="Button1_Click" style="height: 26px; width: 85px" />
<br /><br />
Selected Date:<asp:Label ID="Label1" runat="server"></asp:Label>
</div>
</form>
Replace your MaskedEditValidator with the following:
<asp:MaskedEditValidator ID="MaskedEditValidator1" runat="server"
ControlExtender="TextBox1_MaskedEditExtender" ControlToValidate="TextBox1"
IsValidEmpty="False" EmptyValueMessage="Invalid Date"
InvalidValueMessage="The Date is not valid!">
</asp:MaskedEditValidator>
The key thing is that you needed InvalidValueMessage and/or EmptyValueMessage instead of ErrorText.

Resources