0

I am start to learn simple C#. Please help me How to pass the HTML parameter to .ASPX page to .CS page?

INDEX.axpx PAGE

     <div class="title">
                            <h4>
                                User Login</h4>
                            <div class="option">
                                Sign up for free &raquo;</div>
                        </div>
                        <div class="content">
                            <form method="post" runat="server">
                            <div>
                                <input type="text" runat="server" id="username" name="username" value="" placeholder="username"/>


                            </div>
                            <div>
                                <input type="password" runat="server" id="password" name="password" value="" placeholder="password"/>
                            </div>
                            <div>
                                <input type="button" runat="server" value="Submit" id="submit" onclick=" button_onclick()" />
                            </div>
                            </form>
                            <!-- ## / Panel Content  -->
                        </div>

INDEX.aspx.cs PAGE

 public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        private void button_onclick(object sender, EventArgs e)
        {         
            string uname = Request[username.UniqueID];
            string pass = Request[password.UniqueID];
        }

    }
1
  • 1
    You need to learn some tutorials on Asp.net Commented Oct 2, 2013 at 5:05

2 Answers 2

1

The input elements are runat server and can be referenced directly, so just do this:

public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        private void button_onclick(object sender, EventArgs e)
        {         
            string pass = password.Text;
            string uname = username.Text;
        }

    }
Sign up to request clarification or add additional context in comments.

Comments

0

note that every server element could be accessed via their ID:

runat="server" id="password"

on the server side:

string passwd = password.Text;

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.aspx

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.