|
-
Nov 6th, 2002, 06:36 AM
#1
Thread Starter
Frenzied Member
Problem with asp.net pages
Hi!!
I am a pretty experienced C# programmer, and now the time has come for me to write web applications. I start a new project (web application) and add a button on the page
PHP Code:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication5.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 465px; POSITION: absolute; TOP: 139px" runat="server" Text="Button" Width="140px" Height="75px"></asp:Button>
</form>
</body>
</HTML>
But the page is BLANK when I run the project!!!! Where is the button?
The installation is verified.
best regards
Henrik
-
Nov 6th, 2002, 08:08 AM
#2
Thread Starter
Frenzied Member
Also, I looked at an example at Microsoft quickstart guides, and wrote this aspx file:
PHP Code:
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<HTML>
<HEAD>
<script language="C#" runat="server">
private void SubmitBtn_Click(Object sender, EventArgs e) {
SqlConnection myConnection = new SqlConnection("server=4647117000n26;database=MVS;Trusted_Connection=yes");
SqlDataAdapter myCommand = new SqlDataAdapter("select * from mvs_jobs", myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "mvs_jobs");
MyList.DataSource = ds.Tables["mvs_jobs"].DefaultView;
MyList.DataBind();
}
</script>
</HEAD>
<body>
<center>
<form action="intro8.aspx" method="post" runat="server" ID="Form1">
Name:
<asp:textbox id="Name" runat="server" />
Category:
<asp:dropdownlist id="Category" runat="server">
<asp:listitem>psychology</asp:listitem>
<asp:listitem>business</asp:listitem>
<asp:listitem>popular_comp</asp:listitem>
</asp:dropdownlist>
</h3>
<asp:button text="Lookup" OnClick="SubmitBtn_Click" runat="server" ID="Button1" NAME="Button1" />
<p>
<ASP:DataGrid id="MyList" HeaderStyle-BackColor="#aaaadd" BackColor="#ccccff" runat="server" />
</form>
</center>
</P>
</body>
</HTML>
In the design view, everything looks fine, in the HTML view it also looks good, but when I run the damned webpage, all I get is the TEXT output, no controls whatsoever.
Can ANYONE help me with this???? When designing web applications, the first thing one can ask for is that the controls show up on the page...
best regards
Henrik
-
Nov 6th, 2002, 09:42 AM
#3
It is nothing you did wrong. It is a common problem when .NET is installed, it sometimes craps on IIS. Here is the fix:
You need to run regiis.exe -i from
c:\winnt\microsoft.net\framework\v1.0.3705 directory, where c:\winnt is the
directory in which you installed the OS. Regiis.exe -i re-establishes the
configuration suffixes in IIS used by .NET. You need to run it from the
command line.
-
Nov 6th, 2002, 10:06 AM
#4
Thread Starter
Frenzied Member
YEAH, it solved my problem! Many thanks.
One other thing I have thought about, where should I really write my C# code? For example, if a button click should generate a db call, should I write all that code in the cs file:
PHP Code:
private void Button1_Click(object sender, System.EventArgs e)
{
}
or as a C# script within the aspx file?? I am a bit consfused
best regards
Henrik
-
Nov 6th, 2002, 10:10 AM
#5
either way. You can have all your C# code in a seperate c# file, then you can inherit that file from the aspx page, and have the class in your .cs file inherit the Page object. This technique allows complete seperation of your code and is a good thing to learn. You should do some research on it. The technique is called Code Behind.
but until you learn that, it is perfectly fine to stick the code in the script tag area.
-
Nov 14th, 2002, 06:58 AM
#6
Member
I definitely feel u shud use code-behind
pls do use code-behind. this is an wonderful opportunity for us (microsoft web-developers) to separate design from code forever, an advantage which the java people have used so far.
sujala
-
Nov 15th, 2002, 11:01 AM
#7
Addicted Member
Sujala, Cander,
Interesting to see you both advocate the code behind method. Being a complete newbie to .NET, are there any particular advantages in terms of performance to using code behind? or does it mainly benefit organisation of code? (I am also researching this).
Thanks, Chris
-
Nov 15th, 2002, 11:04 AM
#8
Addicted Member
Duplicate post...sorry...can somebody delete this?
Last edited by csf; Nov 15th, 2002 at 01:31 PM.
-
Nov 15th, 2002, 04:41 PM
#9
Lively Member
one feature is better performance since it is already complied with the code behind it doesnt have to compile at runtime. And it is easier to manage your code and im sure there are others
"All those who wonder are not lost" -j.r.r tolkien
-
Nov 16th, 2002, 12:24 PM
#10
Addicted Member
Interesting.
Do you need Visual Studio .NET to create pre-compiled .NET apps or can you still create the code-behind file in Notepad and compile through the command line?
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|