daveamour
asked on
Page Context
I am writing a method in a class which will send an error message to a client browser as plain text or as Javascript if their browser supports Javascript. I know there are easier ways of doing this but its more of an academic question really.
The code in my class has no page context or access to the Request object etc. I guess I need to pass this from my code in my page to the class, I cant quite get this right though.
Code in web page:
UserMessage.Text = DTS.Classes.Miscellaneous. SendClient ErrorMessa ge (<SomeObjectGoesHere>, "wibble");
Code in Class:
public static string SendClientErrorMessage (<SomeObjectGoesHere>, string ErrorMessage)
{
HttpBrowserCapabilities objBrowser = new HttpBrowserCapabilities();
objBrowser = objRequest.Browser;
if (objBrowser.JavaScript)
{
return "<script language=\"JavaScript\">al ert ('" + ErrorMessage + "');</script>";
}
else
{
return "There was an error as follows: " + ErrorMessage;
}
}
Any ideas please?
The code in my class has no page context or access to the Request object etc. I guess I need to pass this from my code in my page to the class, I cant quite get this right though.
Code in web page:
UserMessage.Text = DTS.Classes.Miscellaneous.
Code in Class:
public static string SendClientErrorMessage (<SomeObjectGoesHere>, string ErrorMessage)
{
HttpBrowserCapabilities objBrowser = new HttpBrowserCapabilities();
objBrowser = objRequest.Browser;
if (objBrowser.JavaScript)
{
return "<script language=\"JavaScript\">al
}
else
{
return "There was an error as follows: " + ErrorMessage;
}
}
Any ideas please?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER