Link to home
Start Free TrialLog in
Avatar of daveamour
daveamourFlag for United Kingdom of Great Britain and Northern Ireland

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.SendClientErrorMessage (<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\">alert ('" + ErrorMessage + "');</script>";
               }
               else
               {
                    return "There was an error as follows: " + ErrorMessage;
               }
          }

Any ideas please?
ASKER CERTIFIED SOLUTION
Avatar of eriksalt
eriksalt

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of daveamour

ASKER

Cheers dude, knew it was something like that, just not familliar enough with the classes yet.