Help With Hardcoding Username And Password For Testing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • marylipscomb
    New Member
    • Apr 2007
    • 51

    Help With Hardcoding Username And Password For Testing

    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="Silv er" 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="#808 0FF" >USERNAME:</asp:Label>&nbsp ;
    </td>
    <td style="width: 211px; height: 28px">
    <asp:TextBox ID="txtUsername " runat="server" Width="136px" />
    <asp:RequiredFi eldValidator ID="rfvUsername " runat="server" ErrorMessage="P lease enter your Username" ControlToValida te="txtUsername " Display="Dynami c" Width="16px">*</asp:RequiredFie ldValidator></td>
    <td style="width: 211px; height: 28px">
    <asp:RegularExp ressionValidato r ID="revUsername " runat="server" ControlToValida te="txtUsername "
    Display="Dynami c" ErrorMessage="Y our Username is invalid"></asp:RegularExpr essionValidator ></td>
    </tr>

    <tr>
    <td style="width: 111px">
    <asp:Label ID="lblPassword " runat="server" Font-Bold="True" ForeColor="#808 0FF" Text="PASSWORD: "
    Width="104px"></asp:Label></td>
    <td style="width: 211px">
    <asp:TextBox ID="txtPassword " runat="server" Width="136px"></asp:TextBox>
    <asp:RequiredFi eldValidator ID="rfvPassword " runat="server" ControlToValida te="txtPassword "
    Display="Dynami c" ErrorMessage="P lease enter your password" Width="16px">*</asp:RequiredFie ldValidator></td>
    <td style="width: 211px">
    <asp:RegularExp ressionValidato r ID="revPassword " runat="server" ControlToValida te="txtPassword "
    Display="Dynami c" ErrorMessage="Y our password must be at least 4 characters long"
    ValidationExpre ssion=" \w{4,}"></asp:RegularExpr essionValidator ></td>

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


    THANK YOU!!!!
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Where you have:
    [code=html]
    <asp:TextBox ID="txtUsername " runat="server" Width="136px" />
    [/code]

    Add in the Text part?
    [code=html]
    <asp:TextBox ID="txtUsername " runat="server" Width="136px" Text="MyUsernam e" />
    [/code]

    Comment

    • marylipscomb
      New Member
      • Apr 2007
      • 51

      #3
      Originally posted by Plater
      Where you have:
      [code=html]
      <asp:TextBox ID="txtUsername " runat="server" Width="136px" />
      [/code]

      Add in the Text part?
      [code=html]
      <asp:TextBox ID="txtUsername " runat="server" Width="136px" Text="MyUsernam e" />
      [/code]


      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="#808 0FF" Text="PASSWORD: "
      Line 47: Width="104px" Text="pass" /></asp:Label></td>
      Line 48: <td style="width: 211px">


      Source File: /WVDODevSite/projectdevelopm ent.aspx Line: 46


      --------------------------------------------------------------------------------
      Version Information: Microsoft .NET Framework Version:2.0.507 27.832; ASP.NET Version:2.0.507 27.832

      Comment

      • marylipscomb
        New Member
        • Apr 2007
        • 51

        #4
        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

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          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.T ext="mypassword ") &(txtUsername.T ext="myusername "))
          {//your special case username and password are correct
          }

          Comment

          • marylipscomb
            New Member
            • Apr 2007
            • 51

            #6
            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="#808 0FF" >USERNAME:</asp:Label>&nbsp ;
            </td>
            <td style="width: 211px; height: 28px">
            <asp:TextBox ID="txtUsername " runat="server" Width="136px" Text="mary"/>
            <asp:RequiredFi eldValidator ID="rfvUsername " runat="server" ErrorMessage="P lease enter your Username" ControlToValida te="txtUsername " Display="Dynami c" Width="16px">*</asp:RequiredFie ldValidator></td>
            <td style="width: 211px; height: 28px">
            <asp:RegularExp ressionValidato r ID="revUsername " runat="server" ControlToValida te="txtUsername "
            Display="Dynami c" ErrorMessage="Y our Username is invalid"></asp:RegularExpr essionValidator ></td>
            </tr>


            <tr>


            if ((txtPassword.T ext = "pass") & (txtUsername.Te xt = "mary"))


            <td style="width: 111px">
            <asp:Label ID="lblPassword " runat="server" Font-Bold="True" ForeColor="#808 0FF" Text="PASSWORD: "
            Width="104px"/></asp:Label></td>
            <td style="width: 211px">
            <asp:TextBox ID="txtPassword " runat="server" Width="136px"></asp:TextBox>
            <asp:RequiredFi eldValidator ID="rfvPassword " runat="server" ControlToValida te="txtPassword "
            Display="Dynami c" ErrorMessage="P lease enter your password" Width="16px">*</asp:RequiredFie ldValidator></td>
            <td style="width: 211px" Text="pass">
            <asp:RegularExp ressionValidato r ID="revPassword " runat="server" ControlToValida te="txtPassword "
            Display="Dynami c" ErrorMessage="Y our password must be at least 4 characters long"
            ValidationExpre ssion=" \w{4,}"></asp:RegularExpr essionValidator ></td>

            Am I putting it in the right spot??
            Thank you so much!!!

            Comment

            • radcaesar
              Recognized Expert Contributor
              • Sep 2006
              • 759

              #7
              As of Plater's reply u have to use that in Codebehind file not in aspx file.

              Comment

              • marylipscomb
                New Member
                • Apr 2007
                • 51

                #8
                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.

                Comment

                • radcaesar
                  Recognized Expert Contributor
                  • Sep 2006
                  • 759

                  #9
                  Yes Exactly, Its aspx.vb file

                  :)

                  Comment

                  • Plater
                    Recognized Expert Expert
                    • Apr 2007
                    • 7872

                    #10
                    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.

                    Comment

                    • kenobewan
                      Recognized Expert Specialist
                      • Dec 2006
                      • 4871

                      #11
                      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 :(.

                      Comment

                      • marylipscomb
                        New Member
                        • Apr 2007
                        • 51

                        #12
                        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.

                        Comment

                        • kenobewan
                          Recognized Expert Specialist
                          • Dec 2006
                          • 4871

                          #13
                          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!

                          Comment

                          Working...