Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...