By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,617 Members | 1,751 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,617 IT Pros & Developers. It's quick & easy.

Help With Hardcoding Username And Password For Testing

P: 51
I am trying to test with a hard coded username and password and I do not know how to put them in my code. For example say I want my username to be mary and password to be pass for testing purposes.

I thought it would be : txtPassword = "pass" txtUsername = "mary"

but that doesn't work.

help please..

Here is my code:

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>BID</title>
</head>
<body>


<span style="font-size: 16pt; color: teal;">
<asp:Image ID="Image1" runat="server" ForeColor="Silver" Height="128px" ImageUrl="~/IMAGES/wvdo_logo.gif"
Width="320px" /><br />
<br />
<br />
Welcome to the Project Development Department of the West Virginia Development Office.
<br />
<br />
Please enter your username and password.</span>

<form id="Form1" runat="server">
<table style="width: 504px">
<tr>
<td style="width: 111px; height: 28px">
<asp:Label ID="lblUsername" runat="server" Height="24px" Width="104px" Font-Bold="True" ForeColor="#8080FF" >USERNAME:</asp:Label>&nbsp;
</td>
<td style="width: 211px; height: 28px">
<asp:TextBox ID="txtUsername" runat="server" Width="136px" />
<asp:RequiredFieldValidator ID="rfvUsername" runat="server" ErrorMessage="Please enter your Username" ControlToValidate="txtUsername" Display="Dynamic" Width="16px">*</asp:RequiredFieldValidator></td>
<td style="width: 211px; height: 28px">
<asp:RegularExpressionValidator ID="revUsername" runat="server" ControlToValidate="txtUsername"
Display="Dynamic" ErrorMessage="Your Username is invalid"></asp:RegularExpressionValidator></td>
</tr>

<tr>
<td style="width: 111px">
<asp:Label ID="lblPassword" runat="server" Font-Bold="True" ForeColor="#8080FF" Text="PASSWORD:"
Width="104px"></asp:Label></td>
<td style="width: 211px">
<asp:TextBox ID="txtPassword" runat="server" Width="136px"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvPassword" runat="server" ControlToValidate="txtPassword"
Display="Dynamic" ErrorMessage="Please enter your password" Width="16px">*</asp:RequiredFieldValidator></td>
<td style="width: 211px">
<asp:RegularExpressionValidator ID="revPassword" runat="server" ControlToValidate="txtPassword"
Display="Dynamic" ErrorMessage="Your password must be at least 4 characters long"
ValidationExpression=" \w{4,}"></asp:RegularExpressionValidator></td>

</tr>
</table>
&nbsp;<br />
&nbsp; &nbsp; &nbsp;&nbsp;<br />
<asp:Button ID="btnSubmit" runat="server" Font-Bold="True" Text="Submit" PostBackUrl="~/projectdevelopmentmain.aspx" /><br />
&nbsp; &nbsp;&nbsp;&nbsp;<br />
<asp:HyperLink ID="hprMainMenu" runat="server" Font-Bold="True" Width="88px" NavigateUrl="~/mainpage.aspx">Main Menu</asp:HyperLink><br />
<br />
<br />
</form>
</body></html>


THANK YOU!!!!
Oct 22 '07 #1
Share this Question
Share on Google+
12 Replies


Plater
Expert 5K+
P: 7,872
Where you have:
Expand|Select|Wrap|Line Numbers
  1. <asp:TextBox ID="txtUsername" runat="server" Width="136px" />
  2.  
Add in the Text part?
Expand|Select|Wrap|Line Numbers
  1. <asp:TextBox ID="txtUsername" runat="server" Width="136px" Text="MyUsername" />
  2.  
Oct 22 '07 #2

P: 51
Where you have:
Expand|Select|Wrap|Line Numbers
  1. <asp:TextBox ID="txtUsername" runat="server" Width="136px" />
  2.  
Add in the Text part?
Expand|Select|Wrap|Line Numbers
  1. <asp:TextBox ID="txtUsername" runat="server" Width="136px" Text="MyUsername" />
  2.  


THANK YOU SO MUCH FOR YOUR QUICK REPLY but I get an error.


Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: The tag contains duplicate 'Text' attributes.

Source Error:


Line 44: <tr>
Line 45: <td style="width: 111px">
Line 46: <asp:Label ID="lblPassword" runat="server" Font-Bold="True" ForeColor="#8080FF" Text="PASSWORD:"
Line 47: Width="104px" Text="pass" /></asp:Label></td>
Line 48: <td style="width: 211px">


Source File: /WVDODevSite/projectdevelopment.aspx Line: 46


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832
Oct 22 '07 #3

P: 51
Maybe I typed the wrong thing, I don't mean hard coded like it always being there I mean like that is the username and password it accepts.
I hope you understand.

thanks
Oct 22 '07 #4

Plater
Expert 5K+
P: 7,872
Ohh haha ok (and you got that error because you put it in the LABEL object which already had a TEXT that gets displayed as like "Password:")

Well where you plan to validate that username/password, add in a special case so that:
[code]
if ((txtPassword.Text="mypassword") &(txtUsername.Text="myusername"))
{//your special case username and password are correct
}
Oct 22 '07 #5

P: 51
hmmm, thank you but I am still having problems.


I put the code in but that actual code shows up on my page:



<form id="Form1" runat="server">
<table style="width: 504px">
<tr>
<td style="width: 111px; height: 28px">
<asp:Label ID="lblUsername" runat="server" Height="24px" Width="104px" Font-Bold="True" ForeColor="#8080FF" >USERNAME:</asp:Label>&nbsp;
</td>
<td style="width: 211px; height: 28px">
<asp:TextBox ID="txtUsername" runat="server" Width="136px" Text="mary"/>
<asp:RequiredFieldValidator ID="rfvUsername" runat="server" ErrorMessage="Please enter your Username" ControlToValidate="txtUsername" Display="Dynamic" Width="16px">*</asp:RequiredFieldValidator></td>
<td style="width: 211px; height: 28px">
<asp:RegularExpressionValidator ID="revUsername" runat="server" ControlToValidate="txtUsername"
Display="Dynamic" ErrorMessage="Your Username is invalid"></asp:RegularExpressionValidator></td>
</tr>


<tr>


if ((txtPassword.Text = "pass") & (txtUsername.Text = "mary"))


<td style="width: 111px">
<asp:Label ID="lblPassword" runat="server" Font-Bold="True" ForeColor="#8080FF" Text="PASSWORD:"
Width="104px"/></asp:Label></td>
<td style="width: 211px">
<asp:TextBox ID="txtPassword" runat="server" Width="136px"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvPassword" runat="server" ControlToValidate="txtPassword"
Display="Dynamic" ErrorMessage="Please enter your password" Width="16px">*</asp:RequiredFieldValidator></td>
<td style="width: 211px" Text="pass">
<asp:RegularExpressionValidator ID="revPassword" runat="server" ControlToValidate="txtPassword"
Display="Dynamic" ErrorMessage="Your password must be at least 4 characters long"
ValidationExpression=" \w{4,}"></asp:RegularExpressionValidator></td>

Am I putting it in the right spot??
Thank you so much!!!
Oct 23 '07 #6

radcaesar
Expert 100+
P: 759
As of Plater's reply u have to use that in Codebehind file not in aspx file.
Oct 23 '07 #7

P: 51
thanks.

oh gosh like a vb file or something? I am new at this and have no idea what you mean by code behind. I had a vb.net class last week and he ended up with a vb file, but I am not sure how to do it.

thank you for your reply.
Oct 23 '07 #8

radcaesar
Expert 100+
P: 759
Yes Exactly, Its aspx.vb file

:)
Oct 23 '07 #9

Plater
Expert 5K+
P: 7,872
If you are working in visual studio (or visual web express) the solution explorer should have files already created for you where you can enter this type of code.
Oct 23 '07 #10

kenobewan
Expert 2.5K+
P: 4,871
Why not store them in the web.config and use them in the aspx.vb via cofiguration appsettings? Sorry but if this is your test design it is unlikely to be a secure application :(.
Oct 23 '07 #11

P: 51
plater---- For some reason files I created without visual studio didn't have the extra vb files when I opened it up in visual studio.

I am just learning this stuff and there is so much to learn.
I am reading about the code behind and I think I am finally starting to get it.
thanks for all yoru help.



kenobewan---

I have no idea what you are talking about right now. haha
I am so new at this.. I think I might have an idea if I remember something from class but right now it just isn't coming to me.

Sometimes I wonder if I am the only one that has so much trouble learning this stuff. Seems like I am the only one that starts at the beginning..
How did you guys learn this stuff??

thanks for all your help.
Oct 23 '07 #12

kenobewan
Expert 2.5K+
P: 4,871
Keep learning, pressure plus time equals evolution. Good thing that you are doing a course, better to learn best practices - saves time. I find you struggle in the dark until suddenly you see the light. If are impatient this is probably not the job for you. Remember that you are always wrong until the code is proven wrong. If its enlightenment you seek understand this, the exception proves the rule.

As to your coding problems, I believe that you already have enough advice from the experts to solve them. If you seek the easy road now, always copying and pasting, you may never see the light. I dont believe anyone becomes an expert in a week. All the best!
Oct 25 '07 #13

Post your reply

Sign in to post your reply or Sign up for a free account.