Web Forms :: How To Enable Requiredfield Validator Based On Condition
Mar 8, 2011
I have required field validator which i set "Enabled="false"" in .ASPX Page. I need to turn on based on condition. For Instance
<asp:label id="lblFirstName" runat="Server">
<asp:textbox id="txtFirstName" runat="server" />
<asp:requiredfieldvalidator id="rfvFirstName" Enabled="false" ControlToValidate="txtFirstName" runat="server" Errormessage="FirstName Required">
</asp:requiredfieldvalidator>
in code behind i've written like this in one of met
if(user=="Admin")
rfvFirstName.Enabled=true;
foreach (IValidator validator inPage.Validators)
View 2 Replies
Similar Messages:
May 17, 2013
I have a dropdownlist ,three text boxes and a submit button.The three text boxes are disabled and enabled based on the condition in dropdownlist.I have provided required field validators in three text boxes.When I click on condition "self" then three text boxees are disabled and submit button click wont enter the values since required field validators prevent that.I have set causes validation property to false.But it wont work for the second condition where i need to enable all the textboxes,If i didnt provide any values it will enter nulll values to db.
View 1 Replies
Oct 25, 2010
I am using c# 2.0 and ASP.NET. I have a button in my web page. I want to enable the button only for the last 5 working days of any month. How to enable the button only for the last 5 working days(business days) that is Monday to Friday.
View 9 Replies
Aug 3, 2013
Suppose the Gridview on the page is for showing the detail records of the Header master record on the same page. How to disable the "Edit" within the Gridview? I would like to disable the "choose" in the Popup of the Gridview and also to disable any buttons of that.
View 1 Replies
Mar 11, 2010
I'm adding RequiredField validators to a group of RadioButtonList controls, and something strange is happening when the page loads. The page renders just fine with no validators tripped, but as soon as I click on one of the radio buttons, the validator for that RadioButtonList fires and shows me the error message. I initially thought that maybe the various validators were cross-linked, so I tried clicking on a radio button in every list, but they all react the same. Here's the code that generates the whole thing:
[Code]....
View 6 Replies
Sep 8, 2012
I got a problem when using required field validator in datalist ,We have 4 polls. In that user must answer two polls which are required.I have added all the four polls in my datalist ,it is displaying fine and while clicking submit button the required field validator is working and giving the error message. Once we answered the required polls and clicking submit button again, all other polls which are not required showing as required one.My poll answer getting submitted thats not a problem ,I want to avoid displaying the error message for non-required polls.Here is my design and code:
<div id="pollQuestion_div" Class="read-messages-poll" runat="server" >
<asp:DataList ID="PollDataList" runat="server" onitemdatabound="PollDataList_ItemDataBound">
<ItemTemplate>
<asp:HiddenField ID="PollIDReqHiddenField" Value='<%# Eval("PollID") %>' runat="server" Visible="false" />
[code]...
View 1 Replies
Feb 16, 2010
Using javascript or jquery, how can I make a Required Field Validator control (of ASP.NET) visible. If we check the viewsource of the Required Field valiator, we can see that the visibility is false initially. $("#spanReqFieldValidator").show() / fadeIn() wont work.
From googling, I understand that jQuery has some issues with visibility attribute.
View 2 Replies
Dec 6, 2010
How to use single requiredfield validator for two or three textboxes in asp.net ?
View 1 Replies
Nov 4, 2010
I have inserted a login page using createuserwizard. but RequiredFieldValidator and CompareValidator does not perform at all and even all textboxes are blank, page is submitted and a record created in database
View 3 Replies
May 7, 2015
I used dropdownlist in page and use ajax CascadingDropDown below are codes
<asp:DropDownList ID="DDLstate" runat="server" CssClass="ddlE"> </asp:DropDownList>
<cc1:CascadingDropDown ID="CDLstate" TargetControlID="DDLstate" PromptText="Select Country"
PromptValue="" ServicePath="../ServiceCS.asmx" ServiceMethod="GetCountries" runat="server" Category="state" />
<asp:RequiredFieldValidator Display="Dynamic" ID="R1" runat="server" ErrorMessage="*لطفاٌ نام استان را وارد نمایید."
ControlToValidate="DDLstate" CssClass="valid7M" InitialValue="0"></asp:RequiredFieldValidator>
Here when I use cascadingDropDown RequiredFieldValidator didn't work I need to use RequiredFieldValidator how I should change codes to use it?
View 1 Replies
May 7, 2015
<cc2:DropDownCheckBoxes ID="cblCustomerList" runat="server" Width="180px">
<Style SelectBoxWidth="195" DropDownBoxBoxWidth="160" DropDownBoxBoxHeight="195"/>
<Items>
<asp:ListItem Text = "Kidneys Donor" Value = "Kidneys Donor"></asp:ListItem>
<asp:ListItem Text = "Lungs Donor" Value = "Lungs Donor" >Eye Donor</asp:ListItem>
<asp:ListItem Text = "Pancreas Donor" Value = "Pancreas Donor" >Blood Donor</asp:ListItem>
<asp:ListItem Text = "One" Value = "1">Heart Donor</asp:ListItem>
<asp:ListItem Text = "One" Value = "1" >Liver Donor</asp:ListItem>
[CODE]...
View 1 Replies
Jul 2, 2010
I want to enable or disable text box in specific row depending on value of field in data source
View 5 Replies
Nov 15, 2010
i have a Time column in my sql db, and i have a page where you inser titme, obviously if you put 0900 it throws back an error, and it needs to be 09:00... how do i enable a validator to do this? needs to be 00:00 format.
View 3 Replies
May 7, 2015
I have a dropdown list for the which values are coming from DB. There is one option name OTHER, when I select other the textbox appears. For that Textbox I have made a required field validator. Till here it works fine. But when I select any other option, still it gives me validator errors. It should not happen. It should only give me required field error when the user doesn't fills the textbox on select of OTHER option. Please see the code.
Dropdown and Textbox code:-
<asp:DropDownList ID="ddlGraduation" runat="server" CssClass="txtfld-popup_drp"></asp:DropDownList>
<asp:RequiredFieldValidator CssClass="error_msg" ID="reqGraduation" runat="server" ControlToValidate="ddlGraduation"
ErrorMessage="Please select graduation details" InitialValue="--Select--" SetFocusOnError="true"></asp:RequiredFieldValidator>
<asp:TextBox ID="txtOther" runat="server" CssClass="txtfld-popup_p"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqOther" runat="server" ControlToValidate="txtOther" ErrorMessage="Please specify your qualification"></asp:RequiredFieldValidator>
JS code for hiding and show the textbox when user select and deselect the OTHER option from dropdown list:-
<script language="javascript" type="text/javascript">
function pageLoad() {
$('#ctl00_ContentPlaceHolder1_txtOther').hide();
$('#ctl00_ContentPlaceHolder1_ddlGraduation').change(function () {
if ($(this).val() === "Other") {
[Code] .....
How to achieve this...
View 1 Replies
Jul 30, 2010
I have CheckedListbox and grid. Based on what are the items checked in listbox that much of items need to be shown in grid. My SQL procedure like ;
select * from Emp
where city in (@Names)
Everything is ok if I am checked any of the item and click OK. If I am nothing checked from the listbox I need to display all of the cities from DB. I need to do this work without modifying my procedure. So need to work out in front/end. If I pass nothing from the code the query seemed as select
* from Emp
where city in ('')
So no records getting...
View 7 Replies
May 7, 2015
In my web page I have a Checkbox (datatype = tinyint/boolean) and 2 Required field validator (whose visibility is false). I want that when I check(tick) the checkbox, then required field validator visible = true, else not.For this I tried this code on Page_Load as well as on save button click, but it is not working:
protected void Page_Load(object sender, EventArgs e) {
if (ChkComplexPass.Checked) {
Regex4.Visible = true;
Regex.Visible = true;
[Code] .....
View 1 Replies
Dec 22, 2010
I want to create new string or stringbuilder based on condition; Example . I am updating a count variable "i"; if i = 100, i need to create a string or stringbuilder; if else i = 200 i need to create a new string or stringbuilder; if else i = 300 i need to create a new string or stringbuilder; and so on how i can achive this?
View 8 Replies
Mar 9, 2011
i have two textboxes and two required filedvalidators for each one.and i have to validate based on the radio button slections.
1)if i select Radiobutton1 it has to validate both textboxes.
2)if i select Radiobutton2 it has to validate only one textbox.
View 2 Replies
Feb 14, 2011
Im using some code I found on how to send files to a FTP address. Its having a Public sub. Within there is there is a credentials set. I need to set different credentials based on which button was clicked. Somthing like:
Public Sub uploadFileUsingFTP(ByVal CompleteFTPPath As String, ByVal CompleteLocalPath As String, Optional ByVal UName As String = "", Optional ByVal PWD As String = "")
If Button1.Click Then
reqObj.Credentials = New NetworkCredential("User1", "PASS")
elseif Anotherbbutton.Click then
reqObj.Credentials = New NetworkCredential("User2", "PASS")
End If
View 3 Replies
Jul 14, 2012
I want to call javascript confirm function in .aspx.cs page .. I have done it by using RegisterStartUpScript javascript code:
<html><head runat="server"><script type="text/javascript" language="javascript">
function alertMe() { //alert("Hello"); if(confirm("File with this Name Already Exists, Do you want to Replace it ?")) {
return true; } else { return false;
} } </script> </head> </html>
.aspx.cs code on button click based on some condition:
Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alertMe();", true);
Now how can I check whether confirm returns true or false, i need to write some code based on confrim's true false return.
View 1 Replies
May 10, 2010
I have one asp.net gridivew where i have written some code and bind it.. itz working fine now my requirment is when ever any gridview row which conatin column 3rd zero(0) i want to hide tht row ..
View 2 Replies
May 22, 2012
i have passed a paramater to the report
if param="Y" then i want to display field2 else field 3
i tried that in expression as
=IIF(paramater!state.value="Y" , fields!add1.value,feilds!add2.value)
but i am not getting
View 1 Replies
Aug 3, 2012
I have a gridview which displays a list of submittted applications with a column that contains an edit link.
<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<asp:LinkButton ID="lnkBtnEdit" runat="server" CommandArgument = '<%# Eval("appID")%>' Text = "Edit" OnClick = "editApp" />
</ItemTemplate>
</asp:TemplateField>
I want to hide the link button if the status (value 1 or 0) of the form is set to 1. Here is the code I am trying to use.
Protected Sub gv1_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
'get the cell cell value
Dim status As Integer
[code]....
I think my mistake lies in getting the status value (as it ouputs 0 for every application).
View 1 Replies
Jun 29, 2010
if i give the 10 number,10 number of same images should be diplayd in the Grid View.
how can i do that.
View 7 Replies
Mar 7, 2011
i m displaying an image in gridview based on condition from sql table. That is if the colum named "availabillity" is A the image will be red n if the value is "NA" the image will be green. i am using RowDataBound event.
but i am getting error as "Cannot implicitly convert type 'System.Web.UI.WebControls.DataControlRowType' to 'bool'".
View 7 Replies