开发者

How can I get data from input fields that are on master page?

开发者 https://www.devze.com 2023-01-19 04:47 出处:网络
I\'m using ASP.NET MVC 2 technology for developing my web site. I have two input fields in my master page (username and password) and one submit button.

I'm using ASP.NET MVC 2 technology for developing my web site. I have two input fields in my master page (username and password) and one submit button.

How can I get data from tho开发者_运维技巧se input fields?

Please help.


You should probably start at this page

When the form is submitted, it should direct to a server-side page that will process the data.

Check out Read Post Data submitted to ASP.Net Form for some details on reading the data with that server side page.


MasterPage:

<asp:TextBox id="txtUsername" runat="server"></asp:TextBox>

Content Code Behind:

string username = ((TextBox)Master.FindControl("txtUsername")).Text;


I found what i was looking for. Thank you for your answers.

<% using (Html.BeginForm("LogOn", "Account", FormMethod.Post))  {  %>

  <%= Html.LabelFor(d => d.UserName)%>:
  <%= Html.EditorFor(d => d.UserName)%>

  <%= Html.LabelFor(d => d.Password)%>:
  <%= Html.Password("Password")%>

  <input type="submit" value="Login" />

  <%= Html.ValidationSummary() %>

<% } %>
0

精彩评论

暂无评论...
验证码 换一张
取 消