Solved

help on understand on how to create this kind of aspx page

Posted on 2008-10-14
24
287 Views
Last Modified: 2012-05-05
hi
in one of my asp pages in my application i simply run a small aspx page. why we do this is because something we need the dot net page to do that.

however when i open that page in the folder its just an apsx page and with code only. and also the lang is C# but in the beginning its like this...
<%@ Page Language="c#" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data.OracleClient" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.UI" %>
what does this mean? i want to create a similar page ...doing the same functionality. so thinking why is this so different ...can anyone help me understnad.
0
Comment
Question by:samir25
  • 11
  • 9
  • 3
  • +1
24 Comments
 
LVL 20

Expert Comment

by:informaniac
ID: 22718414
This is inline coding style of coding in c# wherein the code of C# is written in the aspx page itself.

For writing code in C# u need to write these lines. These are namespaces that contain the definition of the classes used in coding in C#
0
 
LVL 18

Expert Comment

by:Richard Lee
ID: 22718427
This seems to be an Web Server configuration issue. Are you using Internet Information Services (IIS) and can the website running the asp site serve aspx pages?
0
 
LVL 12

Expert Comment

by:rgn2121
ID: 22718439
<%@ Page Language="c#" %>
The Page directive...tells what language is being used for the code files/or code behind files and other elements...

http://msdn.microsoft.com/en-us/library/ydy4x04a.aspx
-------------------------------------------------------------------------------------

The rest are just namespaces as they say.  The reason these are added is so the user doesn't have to add the full name.  For instance, take the StringBuilder class.  It's full name is System.Text.StringBuilder, but if I add the imports at the top of the page then I only have to use StringBuilder as I have imported the System.Text portion.
Here is a listing of the namespaces available...
http://msdn.microsoft.com/en-us/library/ms229335.aspx

I would think that you would have issues with that pages though.  You have declared that you are using C# at the top of the page, but have used Imports statements...C# uses the keyword 'Using' instead of imports and is followed by a semi colon.


0
 
LVL 12

Expert Comment

by:rgn2121
ID: 22718456
Reading the first experts comments I could be wrong about my last statement.  I generally code in VB and have never used Inlline, I always use codebehind or codefiles in this sense.  Imports might be used in inline coding...
0
 
LVL 1

Author Comment

by:samir25
ID: 22718457
what are the steps to create this page... i mean i created a website and used the aspx page nad pasted teh content from this file. it doesnt help me as it gives lot of error...
i m novice ... can guide me through how to create this page ?
also in the folder there is just the aspx page...
0
 
LVL 20

Expert Comment

by:informaniac
ID: 22718481
Is there a Page Directive on the page like

<% Page CodeBehind=""...>

If yes remove it and then paste the code
0
 
LVL 12

Expert Comment

by:rgn2121
ID: 22718496
Not sure what version of Visual Studio you are using, or if you are using it at all, but if you create a new Website Project in VS2005 it will create both a default.aspx and a default.aspx.cs, if you are using C#.

You should be able to click on the plus sign beside the file and see the .cs file.

IF you create a new WebSite Project in VS 2005 you will be asked to select the language and path of your project (name it here) and your site will be created.

Your Default.aspx page will contain the page directive..
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

The default.aspx.cs is the CodeFile listed in the page directive above.  As you add new pages you can either have the code placed in these CodeFiles or have them placed in the .aspx page itself.  Just programmer choice really.

0
 
LVL 1

Author Comment

by:samir25
ID: 22718503
where shud i paste it? in teh 'View Code' side or where i see source and desing on teh aspx page..
0
 
LVL 12

Expert Comment

by:rgn2121
ID: 22718506
Go with informaniac...

I was giving you details about adding a new WebSite Project and using CodeFiles... that's what I get for skimming.  ;)
0
 
LVL 1

Author Comment

by:samir25
ID: 22718509
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="NEWP.aspx.cs" Inherits="NEWP" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
    </div>
    </form>
</body>
</html>


like this is the code for the aspx side? do i replcae this?
0
 
LVL 20

Expert Comment

by:informaniac
ID: 22718521
Yup. u replace all of this if u have the ui also in the page...

if u want ur own ui then u just replace the line

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="NEWP.aspx.cs" Inherits="NEWP" %>

0
 
LVL 12

Accepted Solution

by:
rgn2121 earned 500 total points
ID: 22718537
Like informaniac stated...get rid of everything in the Page directive but <%@ Page Language="C#"  %>

Then right below that copy and paste your ...
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data.OracleClient" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.UI" %>

The you will have to add a Script tag to place your C# code in.
<script runat="server">

</script>


Really, you could add a new web form and unselect the box "place code in separate file".  Once it adds this page it will already be setup for you the way you want and you can delete the default.aspx and default.aspx.cs pages...
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 1

Author Comment

by:samir25
ID: 22718542
i m getting couple of errors
Error      2      The type or namespace name 'OracleClient' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)      C:\oracle\Asp\aspx\testx\WebSite1\TestingPage.aspx      3      
Error      1      Validation (): Element 'html' occurs too few times.      C:\oracle\Asp\aspx\testx\WebSite1\TestingPage.aspx      111      11      C:\...\WebSite1\
0
 
LVL 1

Author Comment

by:samir25
ID: 22718566
i tried to add reference to the oracle client. but cudnt make out what to choose from the option.
what should be the reference name for OrcleClient error i mentioned above.
thansk
0
 
LVL 12

Expert Comment

by:rgn2121
ID: 22718569
I don't know about error 1, but error 2 looks like you didn't add a reference to the system.data.oracleclient.dll.  You need to right click your project and select 'Add reference', then from the list under the .Net tab find it and add it.
0
 
LVL 12

Expert Comment

by:rgn2121
ID: 22718571
in the list you need to look for System.Data.OracleClient
0
 
LVL 1

Author Comment

by:samir25
ID: 22718573
i found the system.data.oracleclient
0
 
LVL 12

Expert Comment

by:rgn2121
ID: 22718578
Error one looks like something on line 111...can you post the code?
0
 
LVL 12

Expert Comment

by:rgn2121
ID: 22718589
As a side...when this is over give any points I might have earned to informaniac...I would have led you down the wrong road since I was unfamiliar with the in-line coding...
0
 
LVL 1

Author Comment

by:samir25
ID: 22718593
ok one more help.
in my original code i aslo have
<%@ Import Namespace="Test.DataStruct" %>
<%@ Import Namespace="Test.TestEvents" %>

i know this is reference to comp specific components. but when i add it in the references in .NET tab or COM tab.. i dont see these? how can i refer them?
0
 
LVL 12

Expert Comment

by:rgn2121
ID: 22718621
Is Test an assembly that you or someone else created to use for this project?  If so you will have to Click the BROWSE tab and browse to where it is located.  If it is another project inside of your current solution, then you need to select the PROJECT tab and it should show up there.
0
 
LVL 12

Expert Comment

by:rgn2121
ID: 22718628
Are you using VS TEAM SYSTEM?
0
 
LVL 1

Author Comment

by:samir25
ID: 22718654
oks ya.. i 1st searched that dll and used the broswe to point to that...all the errors are gone..at least now my page will run.
thanks for the prompt help
0
 
LVL 1

Author Comment

by:samir25
ID: 22718997
hi
can u help me answer to this thread
http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_23815681.html?cid=239#a22718891
as i cant print any output on the page i created?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now