PC Review


Reply
Thread Tools Rate Thread

Adding codebehind files to an app. developed using .net framework

 
 
=?Utf-8?B?ZGluZXNo?=
Guest
Posts: n/a
 
      19th Apr 2005
I made a site using a text editor and the .net framework..compiling it from
the command line. I now have visual studio 2003 and want to alter the
application from within it. Below is one such file, can someone give me an
idea on this?

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data.SqlClient" %>


<script runat="server">

void Page_Load (object Sender, EventArgs e) {


}

void makeselection_Click(Object sender, System.EventArgs e) {
string col;
string cat;
string yea;
string reg;
string cou;
string app;

/*try
{
Session["color"] = color.SelectedItem.Text;
}
catch(System.Exception NotSelected)
{
Session["color"] = "-1";

}
try
{
Session["category"] = category.SelectedItem.Text;
}
catch(System.Exception NotSelected)
{
Session["category"] = "-1";
}
try
{
Session["year"] = year.SelectedItem.Text;
}
catch(System.Exception NotSelected)
{
Session["year"] = "-1";
}

try
{
Session["region"] = region.SelectedItem.Text;
}
catch(System.Exception NotSelected)
{
Session["region"] = "-1";
}
try
{
Session["country"] = country.SelectedItem.Text;
}
catch(System.Exception NotSelected)
{
Session["country"] = "-1";
}

try
{
Session["appellation"] = appellation.SelectedItem.Text;
}
catch(System.Exception NotSelected)
{
Session["appellation"] = "-1";
}

*/
col = color.SelectedItem.Text;
if (col!="") {
Session["color"] = color.SelectedItem.Text;
}
else {
Session["color"] = "";
}

cat = category.SelectedItem.Text;
if (cat!="") {
Session["category"] = category.SelectedItem.Text;
}
else {
Session["category"] = "";
}
yea = year.SelectedItem.Text;
if (yea!="") {
Session["year"] = year.SelectedItem.Text;
}
else {
Session["year"] = "";
}
reg = region.SelectedItem.Text;
if (reg!="") {
Session["region"] = region.SelectedItem.Text;
}
else {
Session["region"] = "";
}
cou = country.SelectedItem.Text;
if (cou!="") {
Session["country"] = region.SelectedItem.Text;
}
else {
Session["country"] = "";
}
app = appellation.SelectedItem.Text;
if (app!="") {
Session["appellation"] = appellation.SelectedItem.Text;

}
else {
Session["appellation"] = "";
}


//Session["color"] = color.SelectedItem.Text;
// Session["category"] = category.SelectedItem.Text;
//Session["price"] = price.SelectedIndex;
// Session["year"] = year.SelectedItem.Text;





Response.Redirect("winelist.aspx");



}
void emailoffer(Object sender, System.EventArgs e)
{



}
</script>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="generator" content="Adobe GoLive">
<title>Untitled Page</title>
<style type="text/css">
<!--
body {
background-color: #FFFFFF;
}
..style2 {font-size: 9px}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if
((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight;
onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH)
location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>
<body>
<p align="center"><img src="e2.jpg" width="694" height="209"></p>
<table width="81%" height="203" border="0">
<tr height="206">
<td width="54%" height="206"> <div
align="center">Shop the largest online assortment of wines from around the
world.From exciting new wines to monthly best sellers, you'll find
greattasting wines for any occasion. </div></td>
<td width="46%" height="206"><img src="top1.gif" width="229"
height="170"></td>
</tr>
</table>
<table width="769" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td width="759"><hr noshade></td>
</tr>
</table>
<p> </p>
<form runat="server">
Category: <aspropDownList id="category" runat="server">
<asp:ListItem Text=""/>
<asp:ListItem Text="Arneis"/>
<asp:ListItem Text="Barbera"/>
<asp:ListItem Text="Bordeaux"/>
<asp:ListItem Text="Cabernet Sauvignon"/>

<asp:ListItem Text="Chardonnay"/>
<asp:ListItem Text="Coastal South Africa"/>

<asp:ListItem Text="Colchagua"/>
<asp:ListItem Text="Corvina"/>
<asp:ListItem Text="Fortified Blend"/>
<asp:ListItem Text="Fume Blanc"/>
<asp:ListItem Text="Gamay"/>
<asp:ListItem Text="Greco"/>
<asp:ListItem Text="Malbec"/>
<asp:ListItem Text="Marsanne"/>
<asp:ListItem Text="Merlot"/>
<asp:ListItem Text="Montepulciano"/>
<asp:ListItem Text="Moscato"/>
<asp:ListItem Text="Muscadet"/>
<asp:ListItem Text="Nebbiolo"/>
<asp:ListItem Text="Pauillac"/>
<asp:ListItem Text="Pinot Blanc"/>
<asp:ListItem Text="Pinot Bianco"/>
<asp:ListItem Text="Pinot Grigio"/>
<asp:ListItem Text="Pinot Gris"/>
<asp:ListItem Text="Pinot Noir"/>
<asp:ListItem Text="Primitivo "/>
<asp:ListItem Text="Red Blend"/>
<asp:ListItem Text="Rhone Valley"/>
<asp:ListItem Text="Riesling "/>
<asp:ListItem Text="Rose Blend "/>
<asp:ListItem Text="Sake"/>
<asp:ListItem Text="Sangiovese"/>
<asp:ListItem Text="Sauvignon Blanc"/>
<asp:ListItem Text="Semillon "/>
<asp:ListItem Text="Shiraz"/>
<asp:ListItem Text="Sparkling Blend "/>
<asp:ListItem Text="Sweet Blend"/>
<asp:ListItem Text="Syrah"/>
<asp:ListItem Text="Tempranillo"/>
<asp:ListItem Text="White"/>
<asp:ListItem Text="White Blend"/>
<asp:ListItem Text="Viognier"/>
<asp:ListItem Text="Zinfandel"/>
</aspropDownList>

Region:
<aspropDownList id="region" runat="server">
<asp:ListItem Text=""/>
<asp:ListItem Text="Abruzzi"/>
<asp:ListItem Text="Alsace"/>
<asp:ListItem Text="Andalucia"/>
<asp:ListItem Text="Bordeaux"/>
<asp:ListItem Text="Burgundy"/>
<asp:ListItem Text="California"/>
<asp:ListItem Text="Campania"/>
<asp:ListItem Text="Catalonia"/>
<asp:ListItem Text="Coastal South Africa"/>

<asp:ListItem Text="France"/>
<asp:ListItem Text="Friuli-Venezia Giulia"/>

<asp:ListItem Text="Languedoc-Roussillon"/>

<asp:ListItem Text="La Rioja"/>
<asp:ListItem Text="Loire Valley"/>
<asp:ListItem Text="Lombardy"/>
<asp:ListItem Text="Madeira"/>
<asp:ListItem Text="Maule Valle"/>
<asp:ListItem Text="Mendoza"/>
<asp:ListItem Text="New South Wales"/>

<asp:ListItem Text="Oregon"/>
<asp:ListItem Text="Paarl"/>
<asp:ListItem Text="Piedmont"/>
<asp:ListItem Text="Puglia"/>
<asp:ListItem Text="Rapel"/>
<asp:ListItem Text="Rhone Valley"/>
<asp:ListItem Text="Sake"/>
<asp:ListItem Text="Sicily"/>
<asp:ListItem Text="Southern"/>
<asp:ListItem Text="South Island, NZ"/>

<asp:ListItem Text="South Africa"/>
<asp:ListItem Text="South Australia "/>

<asp:ListItem Text="Trentino-Alto Adige"/>

<asp:ListItem Text="Tuscany"/>
<asp:ListItem Text="Veneto"/>
<asp:ListItem Text="Vin de Pays"/>
<asp:ListItem Text="Washington"/>
<asp:ListItem Text="Western Australia"/>

</aspropDownList>
Country:

<aspropDownList id=country runat=server>
<asp:ListItem Text=""/>
<asp:ListItem Text="Argentina"/>
<asp:ListItem Text="Australia"/>
<asp:ListItem Text="Chile"/>
<asp:ListItem Text="France"/>
<asp:ListItem Text="Italy"/>
<asp:ListItem Text="Japan"/>
<asp:ListItem Text="New Zealand"/>
<asp:ListItem Text="Spain"/>
<asp:ListItem Text="South Africa"/>
 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      19th Apr 2005
Create a new web project and import all of your ASPX files. You should be
asked if you would like to create code behind pages. Then, fix any compile
errors (from having Page_Load in two places, most likely).

Steps to "fix" your site, if necessary (use what you need)
1. Create file for CodeBehind (assume C# for all your examples)
2. Name same as ASPX with .cs
3. Add Page_Load and other pertinent events (also make sure class file is
named correctly)
4. Put in same folder as ASPX
5. See all in server explorer, include in project
6. Add CodeBehind="" and Inherits="" to the @ tag in the ASPX
7. Make sure you have no dupe events in your ASPX and the code behind

For step 6, add a page to the site and examine the @ tag. It is very easy to
figure out. It is just a bit tedious and time consuming.

In your case, everything in the <script> block should go in code behind
file.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***********************************************
Think outside the box!
***********************************************
"dinesh" <(E-Mail Removed)> wrote in message
news:2BB90D53-813F-4AAE-9A6D-(E-Mail Removed)...
>I made a site using a text editor and the .net framework..compiling it from
> the command line. I now have visual studio 2003 and want to alter the
> application from within it. Below is one such file, can someone give me an
> idea on this?
>
> <%@ Page Language="C#" %>
> <%@ Import Namespace="System.Data.SqlClient" %>
>
>
> <script runat="server">
>
> void Page_Load (object Sender, EventArgs e) {
>
>
> }
>
> void makeselection_Click(Object sender, System.EventArgs e) {
> string col;
> string cat;
> string yea;
> string reg;
> string cou;
> string app;
>
> /*try
> {
> Session["color"] = color.SelectedItem.Text;
> }
> catch(System.Exception NotSelected)
> {
> Session["color"] = "-1";
>
> }
> try
> {
> Session["category"] = category.SelectedItem.Text;
> }
> catch(System.Exception NotSelected)
> {
> Session["category"] = "-1";
> }
> try
> {
> Session["year"] = year.SelectedItem.Text;
> }
> catch(System.Exception NotSelected)
> {
> Session["year"] = "-1";
> }
>
> try
> {
> Session["region"] = region.SelectedItem.Text;
> }
> catch(System.Exception NotSelected)
> {
> Session["region"] = "-1";
> }
> try
> {
> Session["country"] = country.SelectedItem.Text;
> }
> catch(System.Exception NotSelected)
> {
> Session["country"] = "-1";
> }
>
> try
> {
> Session["appellation"] = appellation.SelectedItem.Text;
> }
> catch(System.Exception NotSelected)
> {
> Session["appellation"] = "-1";
> }
>
> */
> col = color.SelectedItem.Text;
> if (col!="") {
> Session["color"] = color.SelectedItem.Text;
> }
> else {
> Session["color"] = "";
> }
>
> cat = category.SelectedItem.Text;
> if (cat!="") {
> Session["category"] = category.SelectedItem.Text;
> }
> else {
> Session["category"] = "";
> }
> yea = year.SelectedItem.Text;
> if (yea!="") {
> Session["year"] = year.SelectedItem.Text;
> }
> else {
> Session["year"] = "";
> }
> reg = region.SelectedItem.Text;
> if (reg!="") {
> Session["region"] = region.SelectedItem.Text;
> }
> else {
> Session["region"] = "";
> }
> cou = country.SelectedItem.Text;
> if (cou!="") {
> Session["country"] = region.SelectedItem.Text;
> }
> else {
> Session["country"] = "";
> }
> app = appellation.SelectedItem.Text;
> if (app!="") {
> Session["appellation"] = appellation.SelectedItem.Text;
>
> }
> else {
> Session["appellation"] = "";
> }
>
>
> //Session["color"] = color.SelectedItem.Text;
> // Session["category"] = category.SelectedItem.Text;
> //Session["price"] = price.SelectedIndex;
> // Session["year"] = year.SelectedItem.Text;
>
>
>
>
>
> Response.Redirect("winelist.aspx");
>
>
>
> }
> void emailoffer(Object sender, System.EventArgs e)
> {
>
>
>
> }
> </script>
> <html>
>
> <head>
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
> <meta name="generator" content="Adobe GoLive">
> <title>Untitled Page</title>
> <style type="text/css">
> <!--
> body {
> background-color: #FFFFFF;
> }
> .style2 {font-size: 9px}
> -->
> </style>
> <script language="JavaScript" type="text/JavaScript">
> <!--
> function MM_reloadPage(init) { //reloads the window if Nav4 resized
> if (init==true) with (navigator) {if
> ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
> document.MM_pgW=innerWidth; document.MM_pgH=innerHeight;
> onresize=MM_reloadPage; }}
> else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH)
> location.reload();
> }
> MM_reloadPage(true);
> //-->
> </script>
> </head>
> <body>
> <p align="center"><img src="e2.jpg" width="694"
> height="209"></p>
> <table width="81%" height="203" border="0">
> <tr height="206">
> <td width="54%" height="206"> <div
> align="center">Shop the largest online assortment of wines from around the
> world.From exciting new wines to monthly best sellers, you'll find
> greattasting wines for any occasion. </div></td>
> <td width="46%" height="206"><img src="top1.gif" width="229"
> height="170"></td>
> </tr>
> </table>
> <table width="769" border="0" cellpadding="0"
> cellspacing="0">
> <tr>
> <td width="759"><hr noshade></td>
> </tr>
> </table>
> <p> </p>
> <form runat="server">
> Category: <aspropDownList id="category" runat="server">
> <asp:ListItem Text=""/>
> <asp:ListItem Text="Arneis"/>
> <asp:ListItem Text="Barbera"/>
> <asp:ListItem Text="Bordeaux"/>
> <asp:ListItem Text="Cabernet Sauvignon"/>
>
> <asp:ListItem Text="Chardonnay"/>
> <asp:ListItem Text="Coastal South Africa"/>
>
> <asp:ListItem Text="Colchagua"/>
> <asp:ListItem Text="Corvina"/>
> <asp:ListItem Text="Fortified Blend"/>
> <asp:ListItem Text="Fume Blanc"/>
> <asp:ListItem Text="Gamay"/>
> <asp:ListItem Text="Greco"/>
> <asp:ListItem Text="Malbec"/>
> <asp:ListItem Text="Marsanne"/>
> <asp:ListItem Text="Merlot"/>
> <asp:ListItem Text="Montepulciano"/>
> <asp:ListItem Text="Moscato"/>
> <asp:ListItem Text="Muscadet"/>
> <asp:ListItem Text="Nebbiolo"/>
> <asp:ListItem Text="Pauillac"/>
> <asp:ListItem Text="Pinot Blanc"/>
> <asp:ListItem Text="Pinot Bianco"/>
> <asp:ListItem Text="Pinot Grigio"/>
> <asp:ListItem Text="Pinot Gris"/>
> <asp:ListItem Text="Pinot Noir"/>
> <asp:ListItem Text="Primitivo "/>
> <asp:ListItem Text="Red Blend"/>
> <asp:ListItem Text="Rhone Valley"/>
> <asp:ListItem Text="Riesling "/>
> <asp:ListItem Text="Rose Blend "/>
> <asp:ListItem Text="Sake"/>
> <asp:ListItem Text="Sangiovese"/>
> <asp:ListItem Text="Sauvignon Blanc"/>
> <asp:ListItem Text="Semillon "/>
> <asp:ListItem Text="Shiraz"/>
> <asp:ListItem Text="Sparkling Blend "/>
> <asp:ListItem Text="Sweet Blend"/>
> <asp:ListItem Text="Syrah"/>
> <asp:ListItem Text="Tempranillo"/>
> <asp:ListItem Text="White"/>
> <asp:ListItem Text="White Blend"/>
> <asp:ListItem Text="Viognier"/>
> <asp:ListItem Text="Zinfandel"/>
> </aspropDownList>
>
> Region:
> <aspropDownList id="region" runat="server">
> <asp:ListItem Text=""/>
> <asp:ListItem Text="Abruzzi"/>
> <asp:ListItem Text="Alsace"/>
> <asp:ListItem Text="Andalucia"/>
> <asp:ListItem Text="Bordeaux"/>
> <asp:ListItem Text="Burgundy"/>
> <asp:ListItem Text="California"/>
> <asp:ListItem Text="Campania"/>
> <asp:ListItem Text="Catalonia"/>
> <asp:ListItem Text="Coastal South Africa"/>
>
> <asp:ListItem Text="France"/>
> <asp:ListItem Text="Friuli-Venezia Giulia"/>
>
> <asp:ListItem Text="Languedoc-Roussillon"/>
>
> <asp:ListItem Text="La Rioja"/>
> <asp:ListItem Text="Loire Valley"/>
> <asp:ListItem Text="Lombardy"/>
> <asp:ListItem Text="Madeira"/>
> <asp:ListItem Text="Maule Valle"/>
> <asp:ListItem Text="Mendoza"/>
> <asp:ListItem Text="New South Wales"/>
>
> <asp:ListItem Text="Oregon"/>
> <asp:ListItem Text="Paarl"/>
> <asp:ListItem Text="Piedmont"/>
> <asp:ListItem Text="Puglia"/>
> <asp:ListItem Text="Rapel"/>
> <asp:ListItem Text="Rhone Valley"/>
> <asp:ListItem Text="Sake"/>
> <asp:ListItem Text="Sicily"/>
> <asp:ListItem Text="Southern"/>
> <asp:ListItem Text="South Island, NZ"/>
>
> <asp:ListItem Text="South Africa"/>
> <asp:ListItem Text="South Australia "/>
>
> <asp:ListItem Text="Trentino-Alto Adige"/>
>
> <asp:ListItem Text="Tuscany"/>
> <asp:ListItem Text="Veneto"/>
> <asp:ListItem Text="Vin de Pays"/>
> <asp:ListItem Text="Washington"/>
> <asp:ListItem Text="Western Australia"/>
>
> </aspropDownList>
> Country:
>
> <aspropDownList id=country runat=server>
> <asp:ListItem Text=""/>
> <asp:ListItem Text="Argentina"/>
> <asp:ListItem Text="Australia"/>
> <asp:ListItem Text="Chile"/>
> <asp:ListItem Text="France"/>
> <asp:ListItem Text="Italy"/>
> <asp:ListItem Text="Japan"/>
> <asp:ListItem Text="New Zealand"/>
> <asp:ListItem Text="Spain"/>
> <asp:ListItem Text="South Africa"/>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deploying Windows app developed in .Net Framework eva100801@hotmail.com Microsoft Dot NET 1 13th Jun 2007 05:25 PM
Running applications developed using framework 1.1 after installing framework 2.0 Feroz Microsoft Dot NET Framework 2 13th Sep 2005 10:35 PM
will a software developed in VS .Net run in a computer without ms framework Vedant Lath Microsoft Dot NET Framework Forms 3 9th Jun 2004 07:52 AM
is it essansial to install .net framework with any software which is developed in .net =?Utf-8?B?cGV0ZXI=?= Microsoft VB .NET 2 11th Feb 2004 12:19 PM
Re: .Net Framework 1.1 is not compatible with programs developed on .Net 1.0 ??! clintonG Microsoft Dot NET Framework 1 23rd Jul 2003 08:13 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:30 AM.