Web Forms :: Textbox Is Required Only If Certain Value Is Chosen From The Dropdownlist?
Oct 19, 2010
I have a textbox and a dropdown list, textbox field is required if the user chooses Y from the dropdown list. There is a little problem with the validator which I'll explain later.
Here is the aspx
[code]...
Although if I click on the button it will not validate the textbox as a required field, but it will be nice to make that red * not showing. Does anybody know a workaround?
View 2 Replies
Similar Messages:
May 4, 2010
I am working on displaying records in grid view. I have a dropdownlist on top of the grid and has items as 5 results per page, 10 results per page and 25 results per page. I would like to display only that many set of records per page as chosen from dropdownlist . I have tried this but don't see any change when i chose different options ..
<asp:DropDownList ID="ddlDisplayPerPage" runat="server" Height="22px"
Width="155px"
onselectedindexchanged="ddlDisplayPerPage_SelectedIndexChanged"
AutoPostBack="True">
<asp:ListItem Value="5">5 Results Per Page</asp:ListItem>
<asp:ListItem Value="10">10 Results per Page</asp:ListItem>
<asp:ListItem Value="25">25 Results per Page</asp:ListItem>
<asp:ListItem Value="50">50 Results per Page</asp:ListItem>
</asp:DropDownList>
protected void ddlDisplayPerPage_SelectedIndexChanged(object sender, EventArgs e)
View 8 Replies
Jul 3, 2012
i want use this control for dropdownlist i wrote below code
<asp:DropDownList ID="DDL2" runat="server" CssClass="DPCDDL">
</asp:DropDownList>
<asp:RequiredFieldValidator Display = "Dynamic" ID="RequiredFieldValidator4" runat="server"
ErrorMessage="please select your classification." ControlToValidate="DDL1" CssClass="valid1"></asp:RequiredFieldValidator>
but it didn't work how i can define that users should select one item from DDL?
View 1 Replies
Oct 13, 2010
My dropdownlist having data from database added with the following item:
DropDownList.Items.Insert(0, new ListItem("Please select", "0"));
View 2 Replies
May 7, 2010
I had a web page with 3 texboxes, i need to enter text one of any three textboxes.
for this i need to put required validator.
View 5 Replies
Mar 28, 2011
trying to set up a form where the user has to either fill out a textbox or check the check box provided. is the a way around the Required field validator as as far as i know it can only work with one item to validate. Not been doing asp for long so not sure on what other options there are.
View 3 Replies
Apr 15, 2010
I populate two dropdownlist in asp.net. Both are assigned to a required field validator.
The codebehind is as below
[Code]....
the designer code is as below
[Code]....
Now what happens is, when i choose a field from the dropdown and once again when i choose the "-- Select--", the validator appears and then disappears.Where am I going wrong?Why doesnt the validator stay?RegardsHema
View 3 Replies
Mar 1, 2011
I have a required validator that I check a textbox clientside, but then on post I check the database for values that have been used. I want to show the error in the RequiredFieldValidator when it post back. How do I do this?
View 1 Replies
Apr 26, 2010
I'm developing an aspx page with vb code.
I am trying to highlight textbox border in red instead on showing an error message in summary. I'm using a required field validator to validate the empty textbox How can i do so?
View 5 Replies
Jul 6, 2010
I have a form that contains several textboxes and each one paired with a required validator. Each box reads a value from a dataset, and on submit click, update the database with the new value. For some reason, one of the validator always returns the error message even if I enter a value in the textbox. My code is something like this.
[Code]....
View 5 Replies
Aug 25, 2010
I'm receiving the following error and can't figure out how to fix it:
The specified string is not in the form required for an e-mail address.
It is only happening as soon as I change the message.From to a textbox rather than a static email address. I have pasted the relevant code below:
[Code]....
I did not post the whole block of code but why is this happening when I change the message.From to emailTextBox.Text instead of a static value? And yes I do have valid email addresses in web.config and code.
View 2 Replies
Jun 3, 2010
i have a file upload control in my form.
How do i check if the user has chosen a file to be uploaded or not.
At present the selected file uploads however if no file is selected the script crashes...
View 2 Replies
Mar 15, 2011
I have Dropdownlist whose value field and text field are bind at runtime. it has --select-- as first item with a value of '0' and the rest of the values are bind at runtime.
I have given validaton group for both the control and the validator as "g1" and Intialvalue=0
But still the page is posting back even if I select '--select--' option.
[Code]....
View 1 Replies
May 22, 2010
I have a script that I am trying to trigger an AJAX AsyncPostBack and have been trying to figure out how to get it to work. After searching the internet for a while I noticed something on all the examples. On the asp:DropDownList they use the autopoastback=true tag. If I add it to my script it works fine, if I remove it it stops working. So my question is why is the autopostback required or if it is not what might I be missing? BTY Everything is in C# and .Net 4
ASP.Net From Page
[Code]....
[Code]....
View 4 Replies
Mar 3, 2011
I'm using Data Annotations to validate my fields, Eventhough field is marked with Required Attribute the DropdownList/ListBox Value doesn't fire up to show they are required. how can I solve this.
View 3 Replies
Apr 14, 2010
I populate two dropdownlist in asp.net. Both are assigned to a required field validator.
The codebehind is as below
if (!Page.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.Add("emp");
dt.Columns.Add("ename");
[Code]....
Now what happens is when I choose a field, and then once again go and choose"-- Select--", the validator appears and disappears.
Why doesnt the validator stay? Where am I going wrong?
View 1 Replies
Sep 28, 2010
My Page to contain 3 textbox with RequiredFieldValidator, too in page button and textbox user write code in textbox and click on button for search using code.
The problem is that it must do I Fill the required textbox before search.
View 7 Replies
Apr 1, 2011
I have a DetailsView on the page and I have made one of the fields a TemplateField. In the EditItemTemplate and InsertItemTemplate I have a DropdownList that is databound to a table in my Sql Server database. I wanted to add an initial value to the DropdownList
namely "- select -" .
I set the AppendDataBoundItems property to true and added the initial value as a ListItem.Markup of the DropdownList
<asp:DropDownList ID="DropDownList_HP" runat="server"
AppendDataBoundItems="True" DataSourceID="SqlDataSource_HP" [code]...
This works fine for new input. The problem is however that the database already has records that were entered through a Windows Application and many of these records has a null value in this field and exceptions are thrown when I tried to open these records
and the system tried to set the SelectedValue of the DropdownList.After some more searching I found this help
http://msdn.microsoft.com/en-us/library/ms366709.aspx
So I changed the ListItem in the DropDownList markup to the following:
<asp:DropDownList ID="DropDownList_RefHospDV4" runat="server"
AppendDataBoundItems="True" DataSourceID="SqlDataSource_RefHosp" [code]...
This now solved the problem of opening a record where the value is null in the database, BUT now the RequiredFieldValidator is not validating anymore to make sure that a databound item is selected for this field and not the initial value "- select -". So basically now it is not checking anymore to see if valid input has been entered for the DropDownList and it accepts "- select -" thus it acts as if the field is not a required field anymore.
In short what is required is that I want to make sure that the user enters a valid selection in the DropDownList, but it must also cater for old records that do not have this field entered yet so that those old records can be opened in the DetailsView .Opening Old records (with null in that field):When these old records are opened in the DetailsView the DropDownlist should show "- select -" when the value in the database is null.
Saving records (old or new records):When saving the record in Insert mode or Update mode the RequiredFieldValidator should show that a valid input is not selected if the DropDownList is still on "- select -".
View 1 Replies
Oct 12, 2010
I have three textboxes on an asp.net webform, how/can I use a required field validator to ensure that at least one of them contains text?
View 2 Replies
Mar 31, 2011
I want to disable the requiredfield validator control for the textbox based on some condition of a variable
if(var==null)
{
//Activate it
}
else
{
//disable it
}
View 1 Replies
Mar 26, 2013
in my module there are data of students for H.S.C., C.E.T, AND H.S.C+C.E.T. so when i run the gridview page all the data of all streams together is displayed so i sort the data using a dropdownlist...means if 1 select the H.S.C in dropdownlist only the H.S.C students are being displayed.so the problem is when i sort the data by selecting a stream in dropdownlist at that time the error message of required field validator is displayed...
1) I wil select the stream from Dropdownlist and click the "sort button"
2) After the data is been sorted and i will enter the values in the TextBox and if i'll miss any of the textbox blank and i click on the "submit button" after dat the error should be displayed
as "Required".
View 1 Replies
Feb 17, 2011
I love MVC, coming from WebForms development, but there are things that don't make any sense to me. The "Error executing child handler" occurs anytime a vast number of things happen, for instance. It's very close to a useless message. In order to get the actual cause, I click on Debug/Exceptions and check the "Common Language Runtime Exceptions", and then reload the View. Presto! It shows the cause of the error.
Another thing I'm wondering about today is the FormCollection value of the Html.CheckBoxFor control. Checkboxes in general seem badly designed in html, and MVC didn't improve on it much. When processing a POST, if a regular checkbox isn't checked, it simply won't show up in the list of posted elements. Great. Instead of just grabbing it by name in the FormCollection and testing its value, instead I have to test whether or not it exists in the FormCollection. Not very intuitive. The Html.CheckBoxFor is a variant on the same theme. It always shows up in the FormCollection, but with a similarly non-intuitive return. If it's not checked, it yields a value of 'false', which can simply be converted to boolean and processed as normal. But if it is checked, it returns 'true,false'. Super. Now, instead of converting its value to a boolean directly, I have to test the string returned for the index of 'true' and return that instead.
I find this close to as aggravating as the Linq To Sql Sum() method bug. If I run a Select() method on a given numeric property and run Sum() to add them all together, if an empty result set is returned by the query it throws an exception. Now, if I was looking at a bunch of totals to add together, and none of them had anything entered, what would I write in the sum box? Error? Exception? Nope, it would be zero. I fully understand that if no results were returned then nulls cannot be added, but according to the intitial documentation this method was supposed to return zero in such an instance regardless, because that's just common sense. Enough of that rant. Does anyone know why this return value was chosen for Html.CheckBoxFor?
View 5 Replies
May 22, 2012
<asp:TextBox ID="txtDraftsmanName" runat="server" Width="200px" CssClass="inputtext" >
</asp:TextBox>*<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="txtDraftsmanName" ErrorMessage= "Please enter Draftsman Name!! " Font-Bold="True" Font-Size="8pt" ForeColor="DarkRed" ValidationGroup="saveDraftsman"></asp:RequiredFieldValidator>
<asp:Button ID="btnSaveDraftsman" runat="server" Text="Save" onclick="btnSaveDraftsman_Click" ValidationGroup="saveDraftsman"/>
View 1 Replies
Jan 2, 2011
I need some help, I have FileUpload control on my asp.net page and Image where I show image which is uploaded on server. What I want that Image show what I choose when I click on Browse in FileUpload control before I upload on server
View 2 Replies
Mar 25, 2013
in my website there is a module in which i m fetching the data of present students in the gridview and i m entering there marks in the gridview textbox column (created by using item template)...I want to add required field validation to the textbox columns so that after clicking the submit button there should be an error message displayed if any of the textbox is empty...
View 1 Replies