Below is the code. Validation summary is never displayed.I trie to add validation group but no help.
<td style="text-align: left">
<asp:TextBox ID="txtccnum" runat="server" Width="100%"></asp:TextBox>
</td>
<td style="text-align: left">
<asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server"
ControlToValidate="txtccnum" ErrorMessage="Credit Card # Cannot be empty">*
</asp:RequiredFieldValidator>
</td>
<asp:ValidationSummary ID="ValidationSummary2" runat="server" ShowMessageBox="True"
ShowSummary="False" DisplayMode="BulletList" Width="700px" />
<asp:Button ID="btnapply" Text="NEXT" runat="server" OnClick="btnapply_Click" />
Because ShowSummary="False"
Make ShowSummary ="True"
I added Page.IsValid flag in button click so it will fire the validations and it worked..
Related
I have 2 Telerik RaddatePicker controls and the button.
<table class="moss2Search">
<tr>
<td>
<div runat="server">
<telerik:RadDatePicker RenderMode="Lightweight" ID="RadDatePicker1" width="100%" runat="server" DateInput-Label="Boarding Start Date">
</telerik:RadDatePicker>
</div>
</td>
<td>
<div runat="server">
<telerik:RadDatePicker RenderMode="Lightweight" ID="RadDatePicker2" width="100%" runat="server" DateInput-Label="Boarding End Date">
</telerik:RadDatePicker>
</div>
</td>
<td>
<div>
<asp:CheckBox ID="chkMerActive" runat="server" Checked="true"/>Active
</div>
</td>
<td>
<%--<asp:Button ID="btnSeacrh" runat="server" Text="Search" OnClick="btnSearch_Click" OnClientClick="return dateValidation();"/> <br />--%>
<telerik:RadButton RenderMode="Lightweight" runat="server" Text="Search" ID="Button1" OnClick="btnSearch_Click" OnClientClicked="validateDates" AutoPostBack="false"></telerik:RadButton>
</td>
</tr>
</table>
How can I validate these 2 controls for a valid date selected, since the user can type a string value as well?
Use the standard validation that comes with the framework. If the user input can be a date the components will have a value, otherwise null or the default so you can also check against that in a a custom validation rule
I have a user control that has two dropdownlists, four textboxes and a gridview in said order. I want the focus to move in this order as tab key is pressed.
I have tabindex property of each control set in sequence (1005, 1010, 1015 ...) except the gridview whose tabindex property is not set to anything.
At page_load I am setting focus to the first dropdownlist.
When page is loaded, focus is on the first dropdownlist, as desired. Then when tab is pressed focus moves to the next dropdownlist, as desired. The problem is when the tab is pressed at this stage, now instead of moving to the first textbox (which has tabindex set to 1015), the focus is moved on the gridview. Note that the gridview do not have its tabindex set to anything. When tab is pressed now, the focus is moved on other user controls on the page, that is, totally out of the discussed user control. Then after several key presses user control do come back to the user control and then move in desired order, that is, first dropdownlist, then second dropdownlist, then first textbox, then second textbox, then third textbox, then fourth textbox. After this it skip the gridview altogether and move to controls which are at the master page.
So, when page is loaded, tab is moving in a different order than what it do once cycle of tabs is completed, that is, all controls are focused.
If I move focus to the first textbox by using mouse click, then press tab then focus is moved to the second textbox as desired, then to third textbox as desired, then to fourth textbox as desired.
I am using two user controls in the page, one of which is discussed above, plus a control directly on page. There are some controls in master page too.
No server or client side event handling happens when tab key is being pressed.
I have tried replace html input control with asp.net textbox control but problem remains.
Request: Please prefer a simple solution, that is one that do not require manually setting tabindex in code-behind because that is not very scalable.
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="GridExpense.ascx.cs" Inherits="StationaryManagementSystem.GridExpense" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<script type="text/javascript">
function MinQuantity_Blurred()
{
$('#' + '<%= hitMaxQuantitySearch.ClientID %>')[0].value = $('#' + '<%= hitMinQuantitySearch.ClientID %>')[0].value;
}
function FromDated_Blurred()
{
$('#' + '<%= txtToDatedSearch.ClientID %>')[0].value = $('#' + '<%= txtFromDatedSearch.ClientID %>')[0].value;
}
</script>
<asp:Panel ID="panel" runat="server">
<table>
<tr>
<td>
<table width="800px">
<tr align="right">
<td class="columnOne">
Item :
</td>
<td class="columnTwo">
<asp:DropDownList ID="ddlItemSearch" runat="server" EnableViewState="true" DataValueField="Id" DataTextField="Name" TabIndex="1005" Width="200px" />
</td>
<td class="columnOne">
Officer :
</td>
<td class="columnTwo">
<asp:DropDownList ID="ddlOfficerSearch" runat="server" EnableViewState="true" DataValueField="Id" DataTextField="Name" TabIndex="1010" Width="200px" />
</td>
</tr>
<tr align="right">
<td align="right" style="width:200px">
From Quantity:
</td>
<td align="left">
<input type="text" id="hitMinQuantitySearch" name="hitMinQuantitySearch" runat="server" maxlength="9" tabindex="1015"
style="width: 90px; text-align: right" onkeydown="return isNumericKeyDown(event, false);" onkeypress="return isNumericKeyPress(event, false);"
onblur="MinQuantity_Blurred();" />
</td>
<td align="right" style="width:200px">
To Quantity:
</td>
<td align="left">
<input type="text" id="hitMaxQuantitySearch" name="hitMaxQuantitySearch" runat="server" maxlength="9" tabindex="1020"
style="width: 90px; text-align: right" onkeydown="return isNumericKeyDown(event, false);" onkeypress="return isNumericKeyPress(event, false);" />
</td>
</tr>
<tr align="right">
<td class="columnOne">
From Dated :
</td>
<td class="columnTwo">
<asp:TextBox ID="txtFromDatedSearch" runat="server" MaxLength="11" TabIndex="1025" onblur="FromDated_Blurred();" Width="90px" />
<asp:CalendarExtender ID="ceFromDatedSearch" runat="server" TargetControlID="txtFromDatedSearch" Format="dd-MMM-yyyy" />
</td>
<td class="columnOne">
To Dated :
</td>
<td class="columnTwo">
<asp:TextBox ID="txtToDatedSearch" runat="server" MaxLength="11" TabIndex="1030" Width="90px" />
<asp:CalendarExtender ID="ceToDatedSearch" runat="server" TargetControlID="txtToDatedSearch" Format="dd-MMM-yyyy" />
</td>
<td align="left">
<asp:Button ID="btnLoad" runat="server" Text="Load" TabIndex="1035" CssClass="foreRed gradientGreen cornerRound" OnClick="btnLoad_Click" />
</td>
</>
</table>
</td>
</tr>
<tr>
<td>
<asp:GridView ID="gv" runat="server" AutoGenerateColumns="False" DataSourceID="ods" AllowSorting="True" AllowPaging="True" PageSize="5"
AutoGenerateSelectButton="True" onrowcommand="gv_RowCommand" CssClass="gridSapphire" PagerStyle-CssClass="pagerSapphire"
AlternatingRowStyle-CssClass="alterSapphire" onpageindexchanged="gv_PageIndexChanged" Width="100%" EmptyDataText="List is empty."
DataKeyNames="Id" EnableViewState="true" onrowdeleted="gv_RowDeleted">
<PagerSettings Mode="Numeric"/>
<Columns>
<asp:TemplateField Visible="false">
<ItemTemplate>
<asp:Label ID="lblIdGrid" runat="server" Text='<%#Eval("Id") %>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="false">
<ItemTemplate>
<asp:Label ID="lblIdItemGrid" runat="server" Text='<%#Eval("IdItem") %>' Style="text-align:left; padding-left:5px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Item" SortExpression="NameItem" ControlStyle-Width="260px">
<ItemTemplate>
<asp:Label ID="lblNameItemGrid" runat="server" Text='<%#Eval("NameItem") %>' Style="text-align:left; padding-left:5px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="false">
<ItemTemplate>
<asp:Label ID="lblIdOfficerGrid" runat="server" Text='<%#Eval("IdOfficer") %>' Style="text-align:left; padding-left:5px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Officer" SortExpression="NameOfficer" ControlStyle-Width="200px">
<ItemTemplate>
<asp:Label ID="lblNameOfficerGrid" runat="server" Text='<%#Eval("NameOfficer") %>' Style="text-align:left; padding-left:5px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Quantity" SortExpression="Quantity" ControlStyle-Width="100px">
<ItemTemplate>
<asp:Label ID="lblQuantityGrid" runat="server" Text='<%#Eval("Quantity") %>' Style="text-align:left; padding-left:5px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Dated" SortExpression="Dated" ControlStyle-Width="100px">
<ItemTemplate>
<asp:Label ID="lblDatedGrid" runat="server" Text='<%# DateTime.Parse(Eval("Dated").ToString()).ToString("dd-MMM-yyyy") %>'
Style="text-align:left; padding-left:5px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbDeleteGrid" runat="server" CommandName="Delete" OnClientClick="return confirm('Are you sure you want to delete this Expense?')">
Delete
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle CssClass="pagerSapphire" />
<AlternatingRowStyle CssClass="alterSapphire" />
</asp:GridView>
<asp:ObjectDataSource ID="ods" runat="server" TypeName="StationaryManagementSystem.Classes.DAL.Expense"
SelectMethod="Search" SelectCountMethod="CountSearch" SortParameterName="sSortExpression" EnablePaging="true"
StartRowIndexParameterName="iZeroIndexStartPage" MaximumRowsParameterName="iSizePage"
onselecting="ods_Selecting"
DeleteMethod="Delete" ondeleting="ods_Deleting">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int64" />
</DeleteParameters>
</asp:ObjectDataSource>
</td>
</tr>
</table>
</asp:Panel>
The problem is not with GridView but with a javascript library select2 that I been using but not showed above. Once this is removed the tab ordering is working almost as desired.
Some problem remains. Now the tab moves correctly through the six controls: the two dropdownlists and the four textboxes, but after that do not go to the gridview. Setting tabindex on gridview do not solve this problem.
Since problem turns out to be different than discussed in this post, I have a separate question for that here.
As said above, some of the problem discussed here still remains. Can anybody tell what is the default tabindex of controls inside a gridview if tabindex of gridview is not set. Tab do work in correct sequence once the gridview get the focus but its very hard to move focus to the grid itself. Actually focus can be moved to the grid by gridview.Focus(); but this do not move focus to the first element inside the gridview. Therefore when tab is pressed next focus moves outside the gridview altogether.
enter code here`<asp:WizardStep ID="CreateUserWizardStep0" runat="server" StepType="Start">
<h1>Bir Hesap Seçin</h1>
<table>
<tr>
<td>
<asp:Label ID="AccountNameLabel" CssClass="grey" runat="server" AssociatedControlID="SearchAccount" >
Kullanıcı Adı:</asp:Label>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="SearchAccount" CssClass="field" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator Visible="true" ID="RequiredFieldValidator1" ControlToValidate="SearchAccount" Display="None" ValidationGroup="kayitFormu" runat="server" ErrorMessage="Girmiş Olduğunuz Hesap Adı Kullanımdadır. Lütfen farklı bir hesap adı deneyiniz."></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="SearchAccountMessage" style="width:400px;" runat="server" ForeColor="red" />
</td>
</tr>
</table>
</asp:WizardStep>`
Is it possible to add some text or some tag under below the create user wizard steps button (previous, next, finish, etc) in createuserwizard??
Have a look at the StepNavigationTemplate. This site should help
I'm not sure if this is what you're looking for, but you can use the navigation templates:
<StartNavigationTemplate>
<asp:Button ID="btnStepNext" runat="server" Text="Next" Width="110" CommandName="MoveNext" CausesValidation="true" />
</StartNavigationTemplate>
<StepNavigationTemplate>
<asp:Button ID="btnStepPrevious" runat="server" Text="Previous" Width="110" CommandName="MovePrevious" CausesValidation="false" />
<asp:Button ID="btnStepNext" runat="server" Text="Next" Width="110" CommandName="MoveNext" CausesValidation="true" />
</StepNavigationTemplate>
<FinishNavigationTemplate>
<asp:Button ID="btnStepPrevious" runat="server" Text="Previous" Width="110" CommandName="MovePrevious" CausesValidation="false" />
<asp:Button ID="btnStepFinish" runat="server" Text="Finish" Width="120" CommandName="MoveComplete" CausesValidation="true" />
</FinishNavigationTemplate>
I have a DataList that has a link button and I want this link button envoke a modal popup. I've copied the mpe code from another application where it works in a gridview. The error is thrown as soon as page is openned and each time the link button is clicked. The error is thrown in the ScriptResource file: "Microsoft JScript runtime error: Sys.ArgumentNullException: Value cannot be null.
Parameter name: elements". I understand something has null value but not sure what. Page has over a thousand lines so I'll just paste the part I'm working on.
<ItemTemplate>
<tr class="AssetMngnt-trHeaderRow_bgColor">
<td valign="top">
<asp:Label ID="lblIdent" runat="server" Text='<%# Eval("Printer_Ident") %>' Visible="false"></asp:Label>
</td>
<td>
<asp:LinkButton ID="lbEdit" runat="server" CausesValidation="False" CommandName="Select" Text="Edit" />
</td>
<td valign="top" nowrap>
<asp:Label ID="lblName" Text='<%# Eval("Network_Name") %>' runat="server" />
</td>
<td valign="top">
<asp:LinkButton ID="lbPrinterModel"
runat="server" CausesValidation="False" CommandName="Select" CommandArgument="ShowAsset"
Text='<%# Eval("Printer_Mfg") + " " + (string)Eval("Printer_Model") %>' />
</td>
<td valign="top">
<asp:Label ID="lblLocation" Text='<%# Eval("Location") %>' runat="server" />
</td>
<td>
<asp:LinkButton ID="LinkButton1"
runat="server" CausesValidation="False" CommandName="Select" CommandArgument="IssueToners"
Text="Issue Toners" />
<asp:Button runat="server" ID="btnShowPopup" style="display:none" />
<ajaxToolkit:ModalPopupExtender runat="server" id="mpeIssueToners"
TargetControlID="btnShowPopup"
PopupControlID="pnlFvIssueTonersModal"
CancelControlID="UpdateCancelButton"
BackgroundCssClass="modalBackground" >
</ajaxToolkit:ModalPopupExtender>
</td>
</tr>
</ItemTemplate>
<asp:Panel runat="server" ID="pnlFvIssueTonersModal" Visible="true" style="display:none">
<asp:Panel runat="server" ID="pnlFvIssueToners" Visible="true">
<div id="AssetMngnt-FloatLeft_alt"">
<!-- ISSUE TONERS FORM VIEW ******************************************************************************** -->
<asp:FormView ID="fvIssueCartridges" runat="server" DataSourceID="ODSIssueCartridges"
OnItemUpdating="fvIssueCartridges_OnItemUpdating" OnItemUpdated="FormView1_Display_Update_Msg"
EnableViewState="False"
EmptyDataRowStyle-CssClass="AssetMngnt-panelRO" >
<EditItemTemplate>
</EditItemTemplate>
</asp:FormView>
<!-- END ISSUE TONERS FORM VIEW **************************************************************************** -->
</div>
</asp:Panel>
<ajaxToolKit:ModalPopupExtender ID="ModalPopupExtender1" BehaviorID="mdlPopup" runat="server"
TargetControlID="div" PopupControlID="div" CancelControlID="btnNo"
OnCancelScript="cancelClick();" BackgroundCssClass="modalBackground" />
<div id="div" runat="server" align="center" class="confirm" style="display:none">
<asp:Label Text="Form is empty - empty records are not allowed."
ForeColor="#000000" runat="server" ID="Label3" /><br />
<asp:Button ID="btnNo" runat="server" Text="Ok" Width="50px" />
</div>
</asp:Panel>
The ModalPopupExtender1 takes care of things inside the FormView.
Thanks,
Risho
I have a simple 2 tab panel setup with 2 validation groups. My problem is that my buttons fire both validation groups.
<cc1:TabPanel ID="TP2" runat="server" HeaderText="" Enabled="true">
<HeaderTemplate>Loan Main</HeaderTemplate>
<ContentTemplate>
<table cellpadding="3" cellspacing="1">
<tr>
<td style="text-align: right"> Quality:</td>
<td><asp:DropDownList ID="ddlAssignedRep" runat="server" DataSourceID="SqlDataSourceAssignedRep"
ValidationGroup="TP2" DataTextField="CreatedBy" DataValueField="CreatedBySFID"
AppendDataBoundItems="True"> </asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSourceAssignedRep" runat="server" ConnectionString="<%$ ConnectionStrings:EUCNET00720 %>"
SelectCommand="SELECT distinct [CreatedBySFID], [CreatedBy] FROM [tblRefiActions] WHERE ([RefiPkey] = #RefiPkey) ORDER BY [CreatedBy]">
<SelectParameters>
<asp:QueryStringParameter Name="RefiPkey" QueryStringField="Pkey" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource></td>
</tr>
<tr>
<td style="text-align: right"><asp:Button ID="btnSave" runat="server" ValidationGroup="TP2" Text="Save" /></td>
<td> </td>
</tr>
</table>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Quality measure is required."
ValidationGroup="TP2" ControlToValidate="ddlQuality" Display="None" SetFocusOnError="True"></asp:RequiredFieldValidator>
</ContentTemplate>
</cc1:TabPanel>
<cc1:TabPanel ID="TP3" runat="server" HeaderText="" Enabled="true">
<HeaderTemplate>Short Payoff</HeaderTemplate>
<ContentTemplate>
<table cellpadding="3" cellspacing="1">
<tr>
<td style="text-align: right"> Amount Short:</td>
<td><asp:TextBox ID="txtShortPayoffAmount" ValidationGroup="TP3" runat="server" Columns="12" MaxLength="12"></asp:TextBox></td>
</tr>
<tr>
<td style="text-align: right"> </td>
<td><asp:Button ID="btnPayoffUpdate" runat="server" Text="Update" ValidationGroup="TP3" /></td>
</tr>
</table>
<br />
<br />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ErrorMessage="Amount can only contain numbers and a single decimal point." ControlToValidate="txtShortPayoffAmount"
ValidationGroup="TP3" Display="None" SetFocusOnError="True"
ValidationExpression="^(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$"> </asp:RegularExpressionValidator>
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" DisplayMode="List" ShowMessageBox="True"
ValidationGroup="TP2" ShowSummary="False" />
<asp:ValidationSummary ID="ValidationSummary2" runat="server" DisplayMode="List"
ValidationGroup="TP3" ShowMessageBox="True" ShowSummary="False" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div>
<cc1:ModalPopupExtender ID="ProgressBarModalPopupExtender" runat="server" BackgroundCssClass="ModalBackground" BehaviorID="ProgressBarModalPopupExtender" TargetControlID="hiddenField1" PopupControlID="Panel1" />
<asp:Panel ID="Panel1" runat="server" Style="display: none; background-color: #C0C0C0;"> <img id="MyImage" src="../Images/Vista_Searching_Bar.gif" alt="" />
<div id="processMessage" style="width: 200px;"> <br />
<br />
Loading...<br />
<br />
</div>
</asp:Panel>
<asp:HiddenField ID="HiddenField1" runat="server" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
<script type="text/javascript">
function StartProgressBar() {
var tp2 = Page_ClientValidate("TP2")
if (tp2 == true) {
var myExtender = $find( ProgressBarModalPopupExtender );
ProgressImg = document.getElementById( MyImage );
setTimeout("ProgressImg.src = ProgressImg.src", 10);
myExtender.show();
return true;
}
}
</script>
I think your validation group names are off. The button and validation summary say the validation group "TabPanel3" "TabPanel1" but your validators say "TP3" and "TP2"
Also you need to make sure that the javascript in your button click is having the ValidationGroup passed in. It looks as though right now it is calling "TP2" no matter which button you click based on your comments below.
Try this for your javascript
function StartProgressBar(ValidationGroup) {
if (Page_ClientValidate(ValidationGroup)) {
//do stuff here on valid
return true;
}
else {
return false;
}
}
Then your button click code should be something like this:
<asp:Button ID="btnSave" OnClientClick="return StartProgressBar('TP2');" runat="server" ValidationGroup="TP2" Text="Save" />
and
<asp:Button ID="btnPayoffUpdate" OnClientClick="return StartProgressBar('TP3');" runat="server" Text="Update" ValidationGroup="TP3" />
Make each click return the value of the validation, that way the click will not continue, because if you return true from that function even if the validation fails I am not sure it will stop since you called the validation manually, I don't know if it will run again. But if you return false it will stop the click, or at least it should.