Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 4th, 2007, 12:01 PM
Authorized User
 
Join Date: Nov 2007
Posts: 67
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Hughesie78
Default Validation based on dropdown list value

I’m trying to determine if a textbox needs validation based on the value selected in the drop down list.
Aspx:
               <asp:DropDownList ID="dp_Marital_status" runat="server">
                        <asp:ListItem></asp:ListItem>
                        <asp:ListItem Text="Divorced" Value="divorced"></asp:ListItem>
                        <asp:ListItem Text="Married" Value="married"></asp:ListItem>
                        <asp:ListItem Text="Single" Value="single"></asp:ListItem>
                        <asp:ListItem Text="Unknown" Value="unknown"></asp:ListItem>
                        <asp:ListItem Text="Widow" Value="widow"></asp:ListItem>
                        <asp:ListItem Text="Separated" Value="separated"></asp:ListItem>
                        <asp:ListItem Text="Other" Value="other"></asp:ListItem>
                    </asp:DropDownList>
<asp:TextBox runat="server" ID="txt_Emp_Name" Width="370px">
</asp:TextBox>

<asp:RequiredFieldValidator ID=valrEmployername runat=server Display=dynamic Text=*
ErrorMessage="Employer name required" Enabled=false
 ControlToValidate=txt_Emp_Name >
</asp:RequiredFieldValidator>

Code behind:
    protected void employment_type_On_textChanged(object sender, EventArgs e)
    {
        string strEmploymentType = Convert.ToString(dp_Emp_Type.SelectedValue);
        if (strEmploymentType.ToString() = "retired")
        {
            valrEmployername.enabled = true;
        }



    }

When I run this I get the error:
CS0131: The left-hand side of an assignment must be a variable, property or indexer
__________________
Thank You
 
Old December 4th, 2007, 12:11 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there.. try taking out () from the tostring...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dropdown list maha .NET Framework 2.0 7 April 28th, 2007 12:32 AM
fill dropdown list with items when parent list isaac_cm Pro PHP 1 July 10th, 2006 05:41 AM
HELP WITH DROPDOWN LIST enavas Excel VBA 1 April 6th, 2004 02:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.