Denaes Posted March 13, 2007 Posted March 13, 2007 Yeah, this is pretty minor and kinda silly, but when I type this line: <script runat="server" language="VB"> and I get to the language tag, it suggests: ecmascript, javascript, jscript & vbscript. I'm using VS2005 and following a book on learning ASP.Net. It's just annoying each time I try to type "VB" "vbscript" is inserted and I have to go back and delete it. In this case I do not have a page directive stating that I'm using VB, so the tag is required. Thanks if anyone knows why. Quote
mandelbrot Posted March 14, 2007 Posted March 14, 2007 Doesn't the language identifier for server-side code go in the page tags at the top of the code?... <%@ Page [color=red]Language="vb"[/color] AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="playtime.WebForm1"%> The script command you're using there will handle ordinary VBScript ... but I'm no expert... Quote
amir100 Posted March 14, 2007 Posted March 14, 2007 OOT. Why not use CodeBehind instead? Quote Amir Syafrudin
amir100 Posted March 14, 2007 Posted March 14, 2007 Whoops. Sorry. I thought the term would be familiar in this forum. OOT = Out Of Topic. I'm using OOT since I'm asking something not relevant to the thread's main discussion. Quote Amir Syafrudin
MrPaul Posted March 14, 2007 Posted March 14, 2007 Script tags If you read Denaes' post properly: I'm using VS2005 and following a book on learning ASP.Net. It's just annoying each time I try to type "VB" "vbscript" is inserted and I have to go back and delete it. In this case I do not have a page directive stating that I'm using VB, so the tag is required. Normally a Page directive would suffice, but in this case Denaes is not using one so the tag is required. Back to Denaes' question, I would say this is an unfortunate lacking in the IDE (not really a bug). As for why it is, I expect that it's just something the IDE developers forgot to include. Many of the samples in MSDN use the script tag in this way, so it is definitely supported, but I suppose the vast majority of the time the script tag will be used for Javascript or VBScript. Either way I doubt there is much you can do about it. Even though you're following a book tutorial, you could probably still use a Page directive as it shouldn't make much difference to what the book is demonstrating. This will allow you to use the <% %> tags to enclose ASP.Net code, and is definitely a better way to do things. However, I would suggest you avoid codebehind until you have the basics down. Good luck :cool: Quote Never trouble another for what you can do for yourself.
Denaes Posted March 14, 2007 Author Posted March 14, 2007 Cool, good to know. Thanks for the info :) I'm beyond that, normally using a code behind file now as well. I guess the book was trying to keep things simple early on. One thing I noticed when they first talked about the <script> tags and assigning a language there as well as in the page directive, my first thought would be that it would be mad cool to have a VB & C# tags in the same page, but the book says that you can only choose one language. so if you have VB as your page directive, you can't do a script block of C#. Can you mix it up with Javascript or one of the intellisense supplied scripting languages? Like have a VB Page and insert a JScript Script block? Quote
amir100 Posted March 15, 2007 Posted March 15, 2007 Re: Script tags However, I would suggest you avoid codebehind until you have the basics down. This is interesting. I always thought it would be a best practice to use codebehind instead. That way your .aspx will be clean from programming codes. Mind explaining your reason MrPaul? Quote Amir Syafrudin
Administrators PlausiblyDamp Posted March 15, 2007 Administrators Posted March 15, 2007 Regardless of the server side choice of language (vb or C#) you can still use client side scripting such as JavaScript as VS should provide intellisense etc. for it as well. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
MrPaul Posted March 15, 2007 Posted March 15, 2007 Codebehind for dummies This is interesting. I always thought it would be a best practice to use codebehind instead. That way your .aspx will be clean from programming codes. Mind explaining your reason MrPaul? Ideally all code would be in a seperate file. In practice this is difficult to achieve with all but the most basic pages - if you need to do anything fancy with databinding then your code will probably be peppered with small code fragments. I am aware than in any scenario it will be possible to have 100% of the code in a codebehind file, but this is often impractical, and can make code harder to read/maintain, not easier. On the contrary, placing code directly into the .aspx page means it performs logically - i.e. where you place a Response.Write is pretty much exactly where the output will appear. Compare this to codebehind's event-based approach. While learning ASP.Net (as Denaes is doing), and especially when following a book which doesn't use codebehind, I recommend avoiding it until you have the basics down. ASP.Net is such a huge and beast that learning is best taken in small steps. Finally, codebehind is even less intuitive to those who program in legacy ASP, PHP, Perl, etc. At the end of the day your primary goal is learning how ASP.Net works as a whole - worrying about where the code is placed is secondary. Quote Never trouble another for what you can do for yourself.
amir100 Posted March 20, 2007 Posted March 20, 2007 Re: Codebehind for dummies What is ideal is not always practical. Right? :D Personally I wanted a clean code using codebehind. But as MrPaul said, I find it hard to do especially when dealing with complex databinding. Quote Amir Syafrudin
mandelbrot Posted March 20, 2007 Posted March 20, 2007 Re: Codebehind for dummies This is all quite interesting, as I'm a newbie to this, and have dealt mainly with Windows apps till now. Could you give some eamples of what would constitute advanced data binding, please? Many thanks, Paul. Quote
amir100 Posted March 21, 2007 Posted March 21, 2007 Re: Codebehind for dummies This is all quite interesting, as I'm a newbie to this, and have dealt mainly with Windows apps till now. Could you give some eamples of what would constitute advanced data binding, please? Complex. Not advance. AFAIK the term simple databinding refers to binding mechanism where you simply bind a database table column to a property of a control or a datagrid column. So my definition of complex databinding would be binding mechanism where you need to do more than what I explained above. For example you have column value it table xyz in your database. If you want it to be shown as is then it's simple data binding. You simply set the datasource and set which column to bind. But if, for example, you want it to be shown using the color red if the content of value is less than or equal to (<=) 55 and green for bigger than (>) 55. In this case you'll need to add some code to your aspx page. I hope that's clear enough. :p Quote Amir Syafrudin
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.