Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

response.write inside a class

Status
Not open for further replies.

ehx6

IS-IT--Management
May 20, 2004
150
US
hi,
I am new in creating classes in c#. Here what I did
using System.Data

public class MyLibrary
{
private int _MyNumber

public int MyNumber
{
get {}
set {
if (value.length >3)
{Response.Write ("The number cannot exceed 3 characters");}
_MyNumber = value;
}
}

The above code did not work, The Response.Write is causing an error [Response could not be found (are you missing a directive or an assembly reference?]

Thanks for your help.
Ehx






}// end of class
 
Response.Write?

Are you writing in ASP?

Otherwise....

using System.Windows.Forms;

MessageBox.Show("The number cannot exceed 3 characters");
Console.WriteLine("The number cannot exceed 3 characters");
 
using System.Web

The System.Web namespace supplies classes and interfaces that enable browser-server communication. This namespace includes the HttpRequest class which provides extensive information about the current HTTP request, the HttpResponse class which manages HTTP output to the client, and the HttpServerUtility class which provides access to server-side utilities and processes. System.Web also includes classes for cookie manipulation, file transfer, exception information, and output cache control.

 
Hi Veep ,

So I can use Response.Write ("to provide user a message") from within the class?
I tried that but failed to get the message delivered.

Am I not suppose to write the following code in the class:
Response.Write("something ");
Or I should use
return ("my text message back to the user")

Also, what is better to use Web User Control or HTML Server Controls in my development.
thanks alot for your help
ehx
 
What about acquiring a reference first to the default Response object?

Code:
public class MyLibrary
{
  private int _MyNumber;
  private System.Web.HttpResponse locResponse;

  public System.Web.HttpResponse Response {
    set{ locResponse = value; }
  }

  public int MyNumber
  {
    get {}
    set {
      if (value.length >3)
      {locResponse.Write ("The number cannot exceed 3 characters");}
      _MyNumber = value;
    }
  }
}
It's lengthy though. [wink]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top