 |
| General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category.
** PLEASE BE SPECIFIC WITH YOUR QUESTION **
When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

December 30th, 2004, 12:22 PM
|
|
Registered User
|
|
Join Date: Dec 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
questions on debugging and 'seeing' variables
I'm having trouble finding information on what to me are some very basic things. There are three things that have had me stumped all week:
1) I have a very simple test page that opens a database and writes the content of a single field. It works just fine on my home machine but not on the web server. What do I need to do to be able to see the error message on the remote server?
2) I'm trying to convert am existing ASP Classic page to a .Net page. I have a button with the following Classic code:
<code>
<form method="post" action="report-ad-problem.asp?i=<%=sIDNum%>" id="form1" name="form1">
<input type="submit" value="Report a problem with this ad." id="submit2" name="submit2">
</form>
</code>
The sIDNum is read from a database record. The code is in a code behind page. How do I get a button click to send the user to a new page with sIDNum as a querystring parameter? I'd prefer to learn how to use the web form controls, but at this point I'll take any method. This is an existing site I'm working on, and I don't want to rewrite the entire site, just the pages I have to, and my customer would prefer to maintain the current look and feel, so I'm stuck with the button/querystring problem.
3) Is there a way to implement # 2 as a web user control? I'd need the web user control to be able recognize the variable sIDNum which comes from the parent page.
I would very much appreciate any help you could give me!
|
|

December 31st, 2004, 05:59 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Diane,
In the ASP.NET 1.x world, things work a bit different. An ASPX page always posts back to itself, and not to a separate "process" page, indeed a common technique in "classic" ASP pages.
Sometimes this can be a real pain (for instance if you need to submit to a different server or application), but often it makes perfect sense.
In your example, this means you should move the code from the process page to the Code Behind of the initial web form. When the button is pushed, the page posts back to itself, while maintaining stuff like the QueryString. Then in the Code Behind of the page, you can check for IsPostBack to determine whether the page has been posted back. If it has, you can still read from the QueryString, and read other info from the form's controls.
I am not sure what you mean with #3. Why do you want to change this to a User Control??
Re: #1: What exactly is not working on the live server? Do you get an error? If so, can you post it here?
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: 36 Degrees by Placebo (Track 4 from the album: Placebo) What's This?
|
|

December 31st, 2004, 11:51 AM
|
|
Registered User
|
|
Join Date: Dec 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank you Imar.
I fixed the problem with #1, mostly, in that I figured out how to run a trace so I could see what was going on. This seemed to 'kick start' the database access on the web host server. But is there a way to get error information when a page fails on a live application? Sometimes an app will work on the development machine, but not when it goes live.
<grin> I know that in the ASP.NET world things work differently - I'm trying to gat a handle on the changes, but all the documentation I can find use the same few, simple examples and I can't figure out how to do most of what I need to do! Sigh. I am using code behind - it makes too much sense to separate the code from the display to not use it.
I want to make this a User Control if I can, because the same set of links appear at the bottom of a number of pages. Some of these links use a querystring parameter, which is where I'm running a problem.
Ok, here's some more information on my problem. I have a page that I'm trying to convert from ASP Classic to ASP.NET. I don't want to convert the entire application just yet, so the input and output need to remain the same. The page is called with a querystring parameter, which I can read fine. That parameter identifies a person, who I need to be able to identify in many of the pages I link to. So, I get the querystring parameter value, get a database record, and do some stuff. Now, I have some button links, and some link button links, most of which need the same querystring parameter. How do I have buttons and link buttons send the user to a URL that is like so:
report-ad-problem.asp?i=<%=sIDNum%>"
and how do I get the value of sIDNum at this point since <%= %> doesn't work any more? Also, the postback examples I've seen use server.transfer, which ignores querystrings.
So how do I do this?
|
|

January 1st, 2005, 03:51 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Diane,
Why can't you redirect? Both:
Response.Redirect("report-ad-problem.asp?i=" & sIDNum)
and
Server.Transfer("report-ad-problem.asp?i=" & sIDNum)
take you to report-ad-problem.asp where you can get the value if i from the QueryString.
To execute this code, you'll need a button (or another control) with a server-side click handler that transfers or redirects the user to the next page.
Check out this FAQ if you want know how to handle run-time errors: http://Imar.Spaanjaars.Com/QuickDocId.aspx?QUICKDOC=268
This solution handles implicit errors, and errors you throw yourself using Throw New Exception.
HtH,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Tiny tears by Tindersticks (From the album: Donkeys 92-97) What's This?
|
|
 |