473,405 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Passing a page to a public class

Hi guys

I'm trying to implement an external class (.cs) for popping a window and
doing various bits and peices. I want to pass to the overloaded constructor a
reference to the page that called the class, so that the class can add some
javascript to the page.

Here's my globals and constructor...

public string e;
public System.Web.UI.Page _sender;

public ACR(string e, System.Web.UI.Page sender)
{
_errorcode = e;
_sender = sender;

DoACR();
}

here's the code for the DoACR() function...

public void DoACR()
{
string cs;
cs = "<script language=\"Javascript\">\n";
cs += "window.open('acr.aspx?c=" + _errorcode + "&p=" +
_sender.Request.ServerVariables["HTTP_URL"].ToString() + "', '_blank',
'width=" +
ConfigurationSettings.AppSettings.Get("System_Repo rtBug_WindowWidth") + ",
height=" +
ConfigurationSettings.AppSettings.Get("System_Repo rtBug_WindowHeight") +
",channelmode=0,directories=0,fullscreen=0,locatio n=0,resizable=0,scrollbars=0,status=0,toolbar=0'); ";
cs += "window.close();\n";
cs += "</script>";
if(!_sender.IsStartupScriptRegistered("close"))
_sender.RegisterStartupScript("close", cs);
}

and from my Page_Load of my page, I'm calling it thus...

ACR crash = new ACR("0x00", this);

I'm getting a "object reference not set to an object" error on the line in
DoACR() that calls _server.Request.ServerVariables["HTTP_URL"].ToString();

How is that happening? As I'm callling my class from Page_Load, I assume
that "this" has been defined as the Page?

Any thoughts appreciated...

Cheers

Dan
Nov 19 '05 #1
3 1313

your problem is here:

_server.Request.ServerVariable*s["HTTP_URL"].ToString()

dump the ".ToString()"

it is a "string" already

cs += "blah" + _server.Request.ServerVariable*s["HTTP_URL"] +
"moreblah";

will work just fine

you owe me a mars bar :-)

Nov 19 '05 #2
Cheers John - I do indeed owe you a Mars bar! In fact, you can have a King
Size Mars bar if you can tell me why ServerVariables["HTTP_URL"] is
empty........!

:o)

"John Rivers" wrote:

your problem is here:

_server.Request.ServerVariableÂ*s["HTTP_URL"].ToString()

dump the ".ToString()"

it is a "string" already

cs += "blah" + _server.Request.ServerVariableÂ*s["HTTP_URL"] +
"moreblah";

will work just fine

you owe me a mars bar :-)

Nov 19 '05 #3
No matter, sorted that one! :o)

"dhnriverside" wrote:
Cheers John - I do indeed owe you a Mars bar! In fact, you can have a King
Size Mars bar if you can tell me why ServerVariables["HTTP_URL"] is
empty........!

:o)

"John Rivers" wrote:

your problem is here:

_server.Request.ServerVariableÂ*s["HTTP_URL"].ToString()

dump the ".ToString()"

it is a "string" already

cs += "blah" + _server.Request.ServerVariableÂ*s["HTTP_URL"] +
"moreblah";

will work just fine

you owe me a mars bar :-)

Nov 19 '05 #4

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

Similar topics

1
by: Matt M | last post by:
Ok. So I'm passing values between web pages, as per microsoft's framework development guide (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/ht...
4
by: rick | last post by:
Does anyone having a working example of passing values between web forms pages? I tried the example in the ms- help but I can't get by the following: To read property values from the source...
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
8
by: JJ | last post by:
Hi, What's the preferred way to pass variables around to different pages now? Or if my reading servers me right they are retained in memory for the life of the app, correct? How do I access...
2
by: Witold Iwaniec via .NET 247 | last post by:
It seems that when you pass an object to a function it is always passed by reference even if it is explicitly declared ByVal. Is it the behavior of VB.Net? Here is sample code from sample Asp.Net...
10
by: Stan | last post by:
There are two ways to pass structured data to a web service: xml === <Order OrderId="123" OrderAmount="234" /> or class =====
0
by: Iain McIntosh | last post by:
Hello if anyone can help me with this I will be very grateful. I have a working version of this program as a windows application, when I try to port it over to c# ASP.NET I can't make it work. ...
5
by: Fernando Chilvarguer | last post by:
I'm sure this has come up before but I could not find any post on it. How can I read a variable or property that has been set on a ASPX page from inside a ASCX control. ASPX code: public...
9
by: Greger | last post by:
Hi, I am building an architecture that passes my custom objects to and from webservices. (Our internal architecture requires me to use webservices to any suggestion to use other remoting...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...

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.