gdboling Posted July 11, 2003 Posted July 11, 2003 I am just getting started with ASP.NET and had a question. Consider the following simple code <script runat="server"> Sub submit(sender As Object, e As EventArgs) lbl1.Text="Hello " & txt1.Text & "!" End Sub </script> <html> <body><form runat="server"> Your name: <asp:TextBox id="txt1" runat="server" /> <asp:Button OnClick="submit" Text="Submit" runat="server" /> <p><asp:Label id="lbl1" runat="server" /></p> </form></body> </html> Can you put the <script> block in a completely seperate file and use it on that page? Thanks. Gregg Quote
Moderators Robby Posted July 11, 2003 Moderators Posted July 11, 2003 Yes, for example the following will link to a JS file in a directory named javascript. 'place the following in the <head> tag. <script src='javascript/main.js'></script> Quote Visit...Bassic Software
*Gurus* Derek Stone Posted July 12, 2003 *Gurus* Posted July 12, 2003 That will work for JavaScript, but certainly not a server side .NET code block. Quote Posting Guidelines
gdboling Posted July 12, 2003 Author Posted July 12, 2003 Ok, so can you help me with a server side .net code block then? Is it even possible what I am asking about? Thanks. Gregg Quote
WebJumper Posted July 12, 2003 Posted July 12, 2003 Serversode code can written in a extra file. For C#: YourPage.aspx.cs For VB: YourPage.aspx.vb First line of your HTML file: <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication1.WebForm1" %> < Should work... Quote
gdboling Posted July 13, 2003 Author Posted July 13, 2003 Perfect, exactly what I was looking for. Thanks. Quote
Moderators Robby Posted July 13, 2003 Moderators Posted July 13, 2003 With VS: using code-behind is the deault. Quote Visit...Bassic Software
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.