Form Submit

N

Neil B

I've set up a page to use to test other pages under development so I can
easily control the parameters that I pass to each of them. I've use the
basic html form structure with a submit button (Code below). When I execute
the submit the browser indicates it's trying to make a connection(page url
not shown) then returns to the original page with no error and no rendering
of the page thats in the action parameter of the form. Any idea what might be
missing or how to get addition information as to what is going on????

Thanks, Neil

..
..
..
<body>
<form id="form1" runat="server" action="~/Home.aspx" method="post">
..
..
..
<input id="Submit1" type="submit" value="Go To Page" /><br />
..
..
</form>
</body>
 
S

Scott M.

If you've created a form in an .aspx page, then the page will automatically
post to itself, regardless of any action="" that you put into the page
(unless you specifically configure cross-page postbacks).
 
N

Neil B

Thanks Scott. That explains a few things.
With that in mind how do you control what html is rendered on different post
backs?

The way VS 2008 .aspx is set up the html and c# are kept separately so how
do you control which part of the html you want rendered on each post back.

In .asp using VB the html and the VB code were all editted together and the
VB code could be used to control which html was used.

Since I'm new to VS2008 and C# any prospective on how these elemets are
related would be appreciated. Links to any good discussions on the subject
would be helpful also.

Thanks, Neil
 
S

Scott M.

Hi Neil,

The first thing I would suggest is to NOT assume that ASP .NET is anything
like the old "Classic ASP". While it's true that there are some superficial
similarities, the way the operate is radically different.

In the old days, we'd just slap something like <%=someVariable%> inline in
the HTML wherever we wanted values to go. With ASP .NET, you have a wide
assortment of server controls to utilize. So, if you know that you are
going to want a server-derived value to eventually show up in a particular
spot on the rendered page, drop a control in that spot as a sort of "place
holder", give that control a good ID and then in your C# code area, write an
event handler (usually Page_Load or Page_Init) to populate that control.
The simplest example would be to put a label on the page, just where you are
going to want a value to show up. Then in the C#, you reference the label
control very easily by refering to it by it's ID and property:

lblResut.Text = someValue;

In short, it will take you some time to get used to the way ASP .NET works
vs. Classic ASP. A really good site to check out is: http://asp.net.

Good luck!

-Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top