Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing .cs variable from .ASPX page

Status
Not open for further replies.

robertfah

Programmer
Mar 20, 2006
380
US
I need to access a variable from my code behind in the .aspx page and it's not working. Here's what I'm trying:

.aspx page - RequiredFieldValidator
Code:
<asp:RequiredFieldValidator ID="rfvEditWebLogin" runat="server" 
                                        ControlToValidate="txtWebLogin" Display="None" ErrorMessage="<%= LoginRequired %>"></asp:RequiredFieldValidator>

and here is the public field in the code behind:
Code:
    public string LoginRequired
    {
        get { return "Error, please try again"; }
    }

When I run it, I don't get anything in the validation summary control, it just appears blank. I have tested it with the string value in the control and verified that it works so it's not a matter of the control not being setup correctly.

Any ideas?
 
BTW, I meant to mention that txtWebLogin AND the RequiredFieldValidator are in an EditTemplate of a gridview.
 
Why do it this way? Just set the ErrorMessage property in the codebehind.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top