|
| |||||||
| |
![]() |
| | LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
| | #1 (permalink) |
| Banned Join Date: Nov 2003
Posts: 1,219
| [VB.NET] Coding Structure and Syntax Help I'm doing a project over Christmas break (for real, this time :P) using SQL Server 2k5 and VB.NET/ASP.NET. Currently, I have the database designed for core functionality and all stored procedures I'll need to manipulate it at this stage of the development. My big question is how to implement it using VB.NET. My understanding so far is that the code structure looks like this: moduleOne.vb // In the Apps_Code directory moduleOne.aspx.vb // The code-behind in the root directory moduleOne.aspx // The front-end file in the root directory My big question is: What would need to go in each one of those? Its a bit overwhelming right now to jump in and just start coding and I've Googled for about 2 hours to no avail of what I'm looking for. FYI: This is just simple database functionality integrated into a website (at this point, anyway) - adding, deleting an entry from a database and displaying the results on the screen. Anyway, if someone can give me a run-down of the orthodox coding practices in regards to the three programming files, and maybe provide a good reference for VB.NET/ASP.NET I would be eternally grateful. |
| | |
| | #2 (permalink) |
| I'm dangerous! Join Date: Jan 2002 Location: Atlanta
Posts: 853
| The aspx file is your typical ASP web page, filled with HTML and ASP tags. It is what web browsers specifically open. The aspx.vb file is strictyly VB code tied to the similarly named aspx file. It is where all of the event handling and Page class function overrides go. While it is possible to put all of that in the aspx file, putting it here is cleaner and allows you to hide most your code from the client. Any old vb file can be referenced from the aspx.vb file, as if it were any normal, mult-sourcefile project. Are you not using VS2005 to create this project? It generates most of the boilerplate code for you. I also recommend using it for Intellisense. As far as databases go, I hope you are familiar with ADO.NET (or not using it) or you have a long road ahead of you. ASP.NET is cake in comparison. edit: Oh and you seem to be missing a Web.config file, which kind of ties the whole project together and allows you to manipulate some global parameters. Last edited by Phelps McManus : 12-28-2007 at 04:05 PM. |
| | |
| | #3 (permalink) | |
| Banned Join Date: Nov 2003
Posts: 1,219
| Quote:
The main reason why I'm doing this is I just got hired on a small software company and they're using this technology on a contract they have. I have no experience with VB.NET and was trying to get a feel with how everything worked. So, for clarification: The .vb file in the App_Code directory will have my calls to the storage procedures and all major functions that will be used to manipulate the database. The .aspx.vb will be handling all of the page code, such as for an "add" button I'd have OnClick being the event and the function in the .vb file that corresponds to that. The .aspx will contain the events I've defined in the .aspx.vb file. I do have Visual Studio 2005, but I'm just trying to get a feel for everything. I'm a little overwhelmed at the moment and have about a week to become productive at this crap. Thanks for the help, it definitely clarified a lot. Do you have any good resources to look at for the kind of thing I'm trying to accomplish? | |
| | |
| | #4 (permalink) |
| Registered User Join Date: Oct 2004
Posts: 1,695
| You can skip using a bunch of ADO.NET and do a ton of database stuff just in the markup with some declarative databinding. Form views, grid views and repeaters are some controls to look into that may do what you need. |
| | |
| | #7 (permalink) |
| Registered User Join Date: Oct 2004
Posts: 1,695
| Yeah, you want to keep your connection string in there and reference it. That way if you need to make a change you just have one place to change it. Usually you don't need to worry about the data that comes from the sqldatasource. Anything that is databound to it will be populated. You can can make the sqldatasource has update select delete insert methods you can call. There are all sorts of paramaters available to use with the datasorce too. Like pulling data from session,query string, form data. |
| | |
| | #8 (permalink) |
| Banned Join Date: Nov 2003
Posts: 1,219
| Well, I'm accessing the database through localized stored procedures in the SQL server. That way, all I'll have to change is one query and it will be affected through the entire program. I'm not entirely sure how data is handled when accessing it in that manner. |
| | |
| | #9 (permalink) |
| I'm dangerous! Join Date: Jan 2002 Location: Atlanta
Posts: 853
| I believe the data is returned as a table or a collection of rows, that you can requery as you please or just "Select *" to look at all of them. I would start looking through MSDN. It will tell you exactly what will be returned and how to manipulate it. They also have sample code in VB, C#, and Java. |
| | |
| | #10 (permalink) |
| Registered User Join Date: Oct 2004
Posts: 1,695
| http://www.fohguild.org/forums/newreply.php?do=newreply&noquote=1&p=940499 When using an SqlDataSource in markup you dont need to worry about the type. You just have to worry about databinding the information to the correct controls. If you are programatically using an sqldatasource the Select command returns an IEnumerable which you can cast to a DataView. For a lot of stuff there should be no reason to start digging in to this but sometimes you need to. For example here is a way to pull some data programatically. Its C# so you will have to translate it to VB. This isn't part of an actual page but I'll just make up a snippet. Code:
|
| | |
| | #12 (permalink) |
| Registered User Join Date: Oct 2004
Posts: 1,695
| I take it you are looking at the signature of an event handler? The first parameter specifies the object that fired the event. The second parameter is a generic EventArgs object that can contain specific information about the event that was fired. Some controls use specific EventArgs. Like a Calendar control has a DayRender event with DayRenderEventArgs. DayRenderEventArgs has a Cell property that lets you modify the css/layout/print text for that particular cell. It also has a Day property that gives you information about the day that is being rendered on the calendar. In WinForms apps, buttons have a MouseClick event which use MouseEventArgs which has properties such as the X and Y cords of the mouse click, the mouse button that was clicked. The object that triggered the event would be the Button that was clicked. |
| | |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
| |