page1.aspx
<input type="text" runat=server id="text1"/>
page2.apx
protected void btnCreateMember_Click(object sender, EventArgs e)
{
text1.text="test";
}
How can I change Input on Page1.aspx through Page2.aspx Method btn开发者_运维知识库CreateMember_Click
I think that you are missing some very basic concepts about ASP.NET MVC here. In ASP.NET MVC there is no such thing as runat="server"
, nor any callbacks. There is no ViewState nor PostBacks. Even if it is based on ASP.NET, ASP.NET MVC is a fundamentally different framework. In ASP.NET MVC you have Models, Controllers and Views. So if you want to send values from one view to another controller action you could use a form with HTML helpers:
<% using (Html.BeginForm("someAction", "someController")) { %>
<%= Html.TextBoxFor(x => x.SomeProperty) %>
<input type="submit" value="OK" />
<% } %>
I would recommend you going through the tutorials here: http://asp.net/mvc to familiarize yourself with the basic notions of MVC.
I see the MVC tags have been removed.
This isn't how webforms work.
If the user is on Page 2 and clicks the "Create Member" button, then you should perform the logic to "create a member" there and redirect as necessary.
If you redirect from Page2 to Page1.aspx, then the page_load event of Page1.aspx should load whatever data it needs and populate any necessary page controls itself.
In other words, each page should be encapsulated to pull, display, and update the data it needs.
精彩评论