473,608 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieve Page Name in asp.net page

Hi All,
Is there a way to get page name in asp.net code behind? I use this to log
error messages in DB ( and in which page the error occured )
For instance , if it is welcome.aspx , then in C# code , I want to get this
page name to store in DB ( There is a way with Request object , but I want
to retrieve the name in another way )

Any help is appreciated :)

Regards
Ersin
Nov 17 '05 #1
2 5230
Page.GetType(). Name will return "YourPageName_a spx". You could replace the
underscore with a dot, which would probably solve your problem. Not sure
how this is any better than using Request.Path though, which I think is
better, as it'll give you the full path to page which errored, making things
easier to debug.

Just my two cents... :-)

Mun


"Ersin Inan" <ei***@onepin.c om> wrote in message
news:Ou******** ******@tk2msftn gp13.phx.gbl...
Hi All,
Is there a way to get page name in asp.net code behind? I use this to log
error messages in DB ( and in which page the error occured )
For instance , if it is welcome.aspx , then in C# code , I want to get this page name to store in DB ( There is a way with Request object , but I want
to retrieve the name in another way )

Any help is appreciated :)

Regards
Ersin


Nov 17 '05 #2
Request.ServerV ariables still works in ASP.NET like it
did in ASP.

Try this... It will list all of the server variables for
you.

Keith

[Visual Basic]
Dim loop1, loop2 As Integer
Dim arr1(), arr2() As String
Dim coll As NameValueCollec tion

' Load ServerVariable collection into NameValueCollec tion
object.
coll=Request.Se rverVariables
' Get names of all keys into a string array.
arr1 = coll.AllKeys
For loop1 = 0 To arr1.GetUpperBo und(0)
Response.Write( "Key: " & arr1(loop1) & "<br>")
arr2 = coll.GetValues( loop1) ' Get all values under
this key.
For loop2 = 0 To arr2.GetUpperBo und(0)
Response.Write( "Value " & CStr(loop2) & ": " & arr2
(loop2) & "<br>")
Next loop2
Next loop1

[C#]
int loop1, loop2;
NameValueCollec tion coll;

// Load ServerVariable collection into
NameValueCollec tion object.
coll=Request.Se rverVariables;
// Get names of all keys into a string array.
String[] arr1 = coll.AllKeys;
for (loop1 = 0; loop1 < arr1.Length; loop1++)
{
Response.Write( "Key: " + arr1[loop1] + "<br>");
String[] arr2=coll.GetVa lues(arr1[loop1]);
for (loop2 = 0; loop2 < arr2.Length; loop2++) {
Response.Write( "Value " + loop2 + ": " + arr2
[loop2] + "<br>");
}
}
-----Original Message-----
Hi All,
Is there a way to get page name in asp.net code behind? I use this to logerror messages in DB ( and in which page the error occured )For instance , if it is welcome.aspx , then in C# code , I want to get thispage name to store in DB ( There is a way with Request object , but I wantto retrieve the name in another way )

Any help is appreciated :)

Regards
Ersin
.

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2425
by: RiGGa | last post by:
Hi, I am relatively new to php however I am working on a site and appear to be getting on quite well. Most of my pages are coded in php and work fine however what I would like to do is be able to retrieve my content from a mysql database. The set up is as follows: Database contains several fields, but for this example I will only require the Page Name and the Content fields. In page name I have the page name i.e. whatson.php and I...
4
1502
by: Edward Lim | last post by:
Hi guys, is it possible to retrieve the name or the id of a form in an ASP.Net page? In the code behind inside the page class, I would like to be able to reference to that "form object" and to retrieve its name or id. is that at all possible? Cheers
2
2845
by: Frank | last post by:
Can I do this? I add a session var in C# and ultimatly want to pass it into a vbscript client side activeX control. This is what I have so far but get " Object Required:'name2' " error. Can anyone suggest a btter way of passing a session var into a vbscript function? <%@ Page language="c#" debug="true" ContentType="text/html"
1
2280
by: Lyners | last post by:
What I need - To retrieve the server name that the ASP application is running on. Why - Our current intranet is on a network where we have users that are on a domain and some that are not. Using I.P. addresses all the users can access the ASP pages. Using I.P. addresses, no one can use our .net pages because the header that is passed back from the server has extra security that require the end users to "log-in" to the server. This is...
6
3862
by: ashok.dhananjeyan | last post by:
Hi, Actually , I wrote one javascript to retrieve the name of the form in one particular page. what i did in this page is, <script> function checkbutton() {
13
3418
by: kev | last post by:
Hi all, I have created a database for equipments. I have a form to register the equipment meaning filling in all the particulars (ID, serial, type, location etc). I have two buttons at the end of the form which is submit and cancel. After i have clicked submit, the information is stored directly into my corresponding database table. My problem here is i need to retrieve back the information submitted to display all the data that the...
4
2069
by: kang jia | last post by:
hi i am doing mailinglist currently. the code in my first page is like this : : <html> <head> <link rel="stylesheet" type="text/css" href="gallery.css" /> <script language="JavaScript"> <!--
1
4094
maxamis4
by: maxamis4 | last post by:
Hello folks, Here is the backgroup. I am creating an agent that can find a user in LDAP and return the last logon date. Now i am not sure if with active directory you can user the SAMAccountName to retrieve the last computer the users logged on to. But i am looking for a place where i can learn this information. I was hoping someone out there could point me in the right direction. Below is my code which i have been working on. It can...
12
77974
lifeisgreat20009
by: lifeisgreat20009 | last post by:
I am a newbie to Struts and JSP...I have been working on the code below for 5 hours now..I googled a lot but couldn't get much help so finally I am here.. Hoping of getting my problem solved. Please give me some idea where I am going wrong ?? I just want to retrieve data from my emp_mstr table and display it using my JSP file... The table emp_mstr is as follows :- CREATE TABLE EMP_MSTR( EMP_NO VARCHAR(10) PRIMARY KEY, PASSWORD...
0
8059
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8000
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8495
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8470
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8145
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8330
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5475
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3960
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2474
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.