Codebehind Example Calling Table Data?

tameza

New Member
Does anyone have an example using codebehind (in vb) where records are pulled out of a table on the .vb page and used to populate the form on the .aspx page?<BR><BR>All I see are examples where form data from .aspx page is submitted from the .vb page to a table.<BR><BR>Can everything in asp.net be done using codebehind? Or is it limited?My understanding of CodeBehind is that it's kind of like COM objects. I said "Kind of"<BR><BR>Imagine in a regular ASP page that you have this:<BR>-a <form>...</form><BR>-a <submit> button<BR>-The <submit> button leads you to another .asp page<BR>-in this other .asp you create an instance of your COM object<BR>-You can now use the properties and methods of this object.<BR><BR>Now when I say "kind of" its because all the logic/code is written in that COM object and NOT IN THE .ASP PAGE ITSELF.<BR>So CodeBehind, to me, is similar to this as in:<BR><BR>I write a regular .aspx page with a <form>...</form> and a couple of buttons. These *buttons* will have an "onclick" attribute that calls a functions or sub. Now instead of writting these Functions and Subs directly in the *same* .aspx page I write then in a .vb file (if VB.NET). Then all I need to do is reference this .vb file into my .aspx page.<BR><BR>You can also think of this as include files in regular .asp pages. It enables you to separate the logic like functions and subs into another file.<BR><BR>-->Can everything in asp.net be done using codebehind<--<BR>The way I see it is, can everything be done in COM objects in regular .asp pages ? Now the answer is yes if I want to but the great thing about NOT doing it all in COM objects is that you can edit an .asp page in notepad and add a Response.Write then save the page without having to re-install the COM Object. <BR>So sometimes its better and sometimes its not<BR><BR>In .NET you wont have these problems (about re-installing the dll and stuff) so Yes you can use CodeBehind to do everything for instance:<BR><BR>------------<BR>...reference the .vb file<BR><html><BR><body><BR><BR></body><BR></html><BR>------------<BR><BR>But the better approach, or microsoft's approach is to use CodeBehind *only* to separate the logic from the controls. Again, you could create an .aspx file with all the server controls (<asp:button....>) and then reference the .vb file which contains all the code for the "onclick" attribute.<BR><BR><BR>-->is it limited?<--<BR>I don't know :(<BR><BR>All of the above is my understanding so I could be wrong all the way, if I'm please advise me so I can return the book I bought ;)<BR><BR>Sincerely<BR>Vlince<BR>
 
Back
Top