Hi
I have a simple web page based on Microsofts "Personal Web Site Starter Kit" starter kit for VS2005.
I have a login page below:
<%@ Page Language="C#" MasterPageFile="~/MasterPa
ge.master"
Title="Title | Home" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<asp:content id="Content1" contentplaceholderid="Main
" runat="server">
<div class="page" id="home">
<div id="sidebar">
<asp:loginview id="LoginArea" runat="server">
<AnonymousTemplate>
<asp:login id="Login1" runat="server" Width="251px" Height="80%">
<layouttemplate>
<p style="text-align: left" class="login">Login to Site</p>
<p class="login" style="text-align: left">
<asp:label runat="server" id="UserNameLabel" CssClass="label" associatedcontrolid="UserN
ame">User Name</asp:label>
<asp:textbox runat="server" id="UserName" cssclass="textbox" accesskey="u" />
<asp:requiredfieldvalidato
r runat="server" id="UserNameRequired" controltovalidate="UserNam
e" validationgroup="Login1" errormessage="User Name is required." tooltip="User Name is required." >*</asp:requiredfieldvalid
ator>
<asp:label runat="server" id="PasswordLabel" CssClass="label" associatedcontrolid="Passw
ord">Passw
ord</asp:l
abel>
<asp:textbox runat="server" id="Password" textmode="Password" cssclass="textbox" accesskey="p" />
<asp:requiredfieldvalidato
r runat="server" id="PasswordRequired" controltovalidate="Passwor
d" validationgroup="Login1" tooltip="Password is required." >*</asp:requiredfieldvalid
ator>
<asp:imagebutton runat="server" id="LoginButton" CommandName="Login" AlternateText="login" skinid="login" CssClass="button" OnClick="LoginButton_Click
"/>
</p>
<p style="text-align: left" class="login"><asp:literal
runat="server" id="FailureText" enableviewstate="False"></
asp:litera
l></p>
</layouttemplate>
</asp:login>
</anonymoustemplate>
<LoggedInTemplate>
<h4><asp:loginname id="LoginName1" runat="server" formatstring="Welcome {0}!" /></h4>
</LoggedInTemplate>
</asp:loginview>
</div>
</div>
</asp:content>
I want to add some code in the button to call a web service function.
The problem That I have is that from the button code I cannot access the username and Password TextBox's from the above code. How do I access them
They are defined in the above code as follows:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextB
ox>
<asp:textbox runat="server" id="Password" textmode="Password" cssclass="textbox" accesskey="p" />
I created the button code by double clicking the button in the web designer.
protected void LoginButton_Click(object sender, ImageClickEventArgs e)
{
WS.WebService LocalWS = new WS.WebService();
LocalWS.Login(UserName.Tex
t, Password.Text, "");
}
The compiler falls over with
The name 'UserName' does not exist in the current context
The name 'Password' does not exist in the current context
Start Free Trial