|
-
Oct 8th, 2003, 02:20 AM
#1
Thread Starter
Frenzied Member
Response write unavailable
I got a really wierd message when I tried to add a response.write
I added a class to my project that would handle db access
I have the colde like this:
Public Class DBAccess
Public Function GetPurchaseOrderLines(parameters) As DataTable
Try
//perform all db here
Return objDt
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Function
Howcome I can't use Response.Write there? It says that it isn't available in this context... Do I have to add namespace reference for this??? That is something new to me....
kind regards
Henrik
-
Oct 9th, 2003, 03:41 AM
#2
You can't use response in a class as a class isn't linked to any webpage so it has nowhere to write the response to. How about passing the ex.message back as a string to the calling procedure and then response.write form there.
-
Oct 9th, 2003, 05:34 PM
#3
Or this:
PHP Code:
'In the external class
Public Sub Something (param 1 as datatype, [b]objResponse as object[/b])
'Code
objResponse.Write(txtVariable)
'Code
End Sub
Then, you call your sub like so:
Something(myVar, Response)
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Oct 10th, 2003, 06:10 AM
#4
Fanatic Member
Or will this work for you?
using System.Web;
....
HttpContext.Current.Response.Write(ex.Message)
-
Oct 10th, 2003, 11:03 AM
#5
No because your external class is not inherited from a class that inherits your page object. (IE, it does not have a context with which to write)
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Oct 10th, 2003, 11:27 AM
#6
Fanatic Member
But as long as it is instantiated from an object with a valid context (which it presumably is) then
System.Web.HttpContext.Current.Response.Write will be able to use that context I think.
-
Oct 10th, 2003, 11:33 AM
#7
The ultimate proof would be just to try it.
If this code is in a secondary page (as the original poster indicated), I don't think it would work.
Admittedtly, I have not tried your code in the past, but I have tried the response.write and that's when I had tofind another work around.
When I get some free time here, Ill try that.
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
May 27th, 2004, 06:52 AM
#8
I wonder how many charact
You just pass a reference to the page to your calling function.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|