Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 321
  • Last Modified:

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

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
samir25
Asked:
samir25
  • 11
  • 9
  • 3
  • +1
1 Solution
 
informaniacCommented:
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
 
Richard LeeSoftware EnthusiastCommented:
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
 
rgn2121Commented:
<%@ 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
rgn2121Commented:
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
 
samir25Author Commented:
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
 
informaniacCommented:
Is there a Page Directive on the page like

<% Page CodeBehind=""...>

If yes remove it and then paste the code
0
 
rgn2121Commented:
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
 
samir25Author Commented:
where shud i paste it? in teh 'View Code' side or where i see source and desing on teh aspx page..
0
 
rgn2121Commented:
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
 
samir25Author Commented:
<%@ 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
 
informaniacCommented:
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
 
rgn2121Commented:
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
 
samir25Author Commented:
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
 
samir25Author Commented:
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
 
rgn2121Commented:
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
 
rgn2121Commented:
in the list you need to look for System.Data.OracleClient
0
 
samir25Author Commented:
i found the system.data.oracleclient
0
 
rgn2121Commented:
Error one looks like something on line 111...can you post the code?
0
 
rgn2121Commented:
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
 
samir25Author Commented:
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
 
rgn2121Commented:
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
 
rgn2121Commented:
Are you using VS TEAM SYSTEM?
0
 
samir25Author Commented:
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
 
samir25Author Commented:
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 11
  • 9
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now