Event Handling Pt2

Results 1 to 2 of 2

Thread: Event Handling Pt2

  1. #1
    Join Date
    Dec 1969

    Default Event Handling Pt2

    In a webform in vb.net how do i put an sql statement inside an event handler?<BR>Are there further implications(code)in the rest of the program?<BR>How do I get the event to generate labels of a database name or field for the results of the sql statement?<BR><BR>We now need all this in a table form<BR>

  2. #2
    Join Date
    Dec 1969

    Default Understand the implications...

    If you do ANYTHING with a SQL statement, it has to take place BACK ON THE SERVER!<BR><BR>And you should read this FAQ, then. It was written for old-fashioned ASP, but the concepts apply equally to ASP.NET:<BR>http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=169<BR><BR>See the point?<BR><BR>The only way that code on the server can possibly happen is for the &#060;FORM&#062; to be *SUBMITTED* from the browser back to the server! Now, there&#039;s no reason this can&#039;t be done via any kind of event handler in the client-side form. Essentially, the event handler ends up doing something like<BR> &#060;INPUT ... onWhatever="this.form.submit( );"&#062;<BR><BR>And because ASP.NET has this hairy code and hairy hidden fields that remember state for you, it can be made to work. The browser submits the form and then promptly *WIPES OUT ALL CONTENT* in the browser window! So the ASP.NET page has to RE-SEND *all* of the content back to the browser--including remembering all the form fields that the user has entered up to that point!--as well as performing whatever operation you wanted it to do because of the event.<BR><BR>SO...<BR><BR>The short answer might be: Is there a better way to do this???<BR><BR>Is there some way to avoid having to do the roundtrip to the server? Such as by dumping a lot more data out to the browser in the first place and using client-side code to bring up the right info when the event happens?<BR><BR>If this is for an inTRAnet, that kind of refinement may not be needed; the performance of the data flying back and forth from browser to web server is probably not even noticable on your company&#039;s LAN. But if this is an inTERnet app...well, you should look really carefully at whether this is the best way to perform this operation.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts