Re: ASP.Net Newbie Questions

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Natan (nvivo_at_mandic.com.br)
Date: 11/27/04


Date: Sat, 27 Nov 2004 18:27:43 -0200

MDW wrote:

> I'm a bit unclear as to what you mean by "client-side events on the server".
> When I hear client-side, I think of JavaScript and stuff like form
> validation. Is ASP.Net trying to pre-empt the kind of things that JavaScript
> does? There does seem to be quite a bit of architecture in place that could
> be used to validate user input. Is that the whole purpose of the PostBack
> entity?

See, you must understand how a page in asp.net works first. First, the
ViewState...

ViewState is actually a serialized hidden field in a <form
runat='server'> that asp.net manages automatically for you. all the data
on every <control runat="server"> you put in a form are stored in that
field.

Now, when the guy said "client-side event on the server", that means the
action happened in the client, but when you posted the page, the server
does something, not the client. This works because asp.net manages the
viewstate storing how the fields look before rendering the page, and
comparing with how they look after you submit a page.

Because GET is not good for sending lots data (viewstate can become big
  depending on what you store in it), then the default is POST. So you
have "postback". You post the page, asp.net detects what happened
comparing data and checking fields you sent, and fires the events.

Yes, it ends sending and receiving more data then you would need, but
the benefits are bigger... and data compressing should take care of most
problems.

It's not trying to "replace javascript". It's just a way to control what
asp.net must do.

> Also, if the philosophy of ASP.Net is not to have everything on one page,
> does that mean that Request.Form still exists? Can I still put
> "action=nextpage.aspx" on a form to have that form post its data to another
> page?

Yes. Actually you can program exactly like you did in old ASP. But you
will figure out that it sucks because you have much better ways to do
things in asp.net.

Of course in some cases you still need to do some Request.QueryString...
  but only when you need to pass date to other page. As you can do most
of the job in the same page, you will use it, but not as much as you
used to.

> As I've said, the book I'm using seems to be pretty sub-par. I can't find
> the answers in there, and all the examples I can find use single pages -
> there is no "how to post a form to another page" example. I apologize if
> these are ridiculously stupid questions.

UNfortunately, you cant. ASP.NET automatically modify any "<form
runat="server"> to post to itself. You can post to other page if you
don't use "runat="server"".. but then you don't have many features
asp.net gives you.

Sometimes i miss this too. But in many cases you will see there are
better ways to do somethings. Try to understand how it should be done,
and why instead of trying to do things the old way. I think it will be
better this way.

btw, sorry for my english.. =)

[]'s



Relevant Pages

  • Re: How to handle invalid entries in form submission
    ... You have three basic approaches for data validation: ... Client-side: Use javascript to check the form data before it is posted. ... Server-side: Use ASP to check the posted data and react accordingly ...
    (microsoft.public.inetserver.asp.general)
  • Re: [PHP] Numbers, Numbers everywhere! Need some Dollar help.
    ... In my form I have an area where the user enters in the payment amount: ... to put in the dollar AND cents? ... If you want it squarely on the client side, then use javascript. ... client-side via a client-side language like JScript, VBScript, etc. ...
    (php.general)
  • Re: Need to start over on a project: vb or c#?
    ... development; server-side and client-side. ... The client requires mastery of JavaScript and even more so now with AJAX and ... JavaScript and C# syntax is exactly ... controls right in the declaration. ...
    (microsoft.public.dotnet.framework.aspnet)
  • What future holds for Javascript? [WAS: Store the answer to a question]
    ... JavaScript - refers to the client-side language used in Gecko ... JScript - refers to the language trademark reserved by Microsoft ... Corporation and latter in Mozilla Foundation, ...
    (comp.lang.javascript)
  • Re: DOM-scripting -- FF problem -- SOLVED
    ... Server-side is where any necessary validation is never optional. ... I asked in a FF forum, solution was to put 'return false' after function call; have now succeeded in both validate (client-side) and connect to server w/AJAX to send email...:) ... Browsers can be configured to have javascript disabled. ... However, the validation might fail on the lcient, so you need to *revalidate* on the server. ...
    (comp.lang.javascript)