 |
| ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.x and 2.0 Application Design 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 6th, 2003, 01:25 AM
|
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Peter,
A 'script-able' version of an HTML page is a new concept to me. I've now converted the NavFrameset.htm page to NavFrameset.aspx. In the NavFrameset.aspx.cs page I've added:
private void Page_Load(object sender, System.EventArgs e) {
// Load NameValueCollection object.
NameValueCollection coll=Request.QueryString;
// Get names of all keys into a string array.
String[] arr1 = coll.AllKeys;
if( arr1[0] != null) {
String[] arr2 = coll.GetValues(arr1[0]); // contains the string
}
}
That much works and now I know what a QueryString is. It contains "Catalog.htm".
But how do I change the statement on the NavFrameset.aspx page from <frame name="main" src="NLELogo.aspx">
to <frame name="main" src="Catalog.htm">? I tried a string variable declared in the page class - nope!
Don't I want to make the change at the server instead of at the client?
(I've removed the javascript.)
Sandra MacGregor
|
|

December 8th, 2003, 01:37 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
Sandra,
Rather than trying to go back and forth with questions and samples, I created a full sample for you. Click here to take a look. There's a link to download the whole thing in the sample. The sample is pretty basic, I just tossed it together to show the concept but it will hopefully clear things up.
I will at least make one response to you posts: You are already doing "script-able" page if you are working in ASP.net. What confused me in this thread was that the pages you referenced are .htm which typically rules them out of being scripted/programmable (at least on the server side).
Peter
------------------------------------------------------
Work smarter, not harder.
|
|

December 9th, 2003, 03:15 AM
|
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Fantastic Peter,
Thanks so much for the code! The page was .htm because that's what the VS.NET Frameset wisard generated. Now I know to change it. I'm just learning all this Web stuff (my background in C, C++, embedded, assembly, etc.) So this is great fun - but I couldn't feel more helpless. The javascript is very c-like, I'll get a book.
I've learned how to move a variable from the C# to the html code. "<%variable%>"
But still, with or without the checking in javascript, when the not-framed page returns to the frame in the frameset it flickers - it draws a blank page first, then the client-side variable is read and another request is sent to the server.
I was wondering if there's any way to have that be server side code. At your suggestion I've been on the web looking all over and can't find again a page discussing an HTML tag <SERVERSIDE>. i
I have found SSI. Is that what the line in your code is?:
Thanks again
Does IE know shtml?
That's 3 questions. Please answer only the first one? "is there any way to have that be server side code."
Sandra MacGregor
|
|

December 9th, 2003, 10:40 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
I'm not sure what the flicker is that you speak of unless you are referring to when the non framed page is requested and draw within a frame, and then rights itself by re-requesting itself in the main browser window.
There's no way for a page running on the server side to know where it's living in the browser. It's just another isolated page request. The server has no knowledge of the browser with regards to where the page requests are coming from within the browser object hierarchy (window, frames, iframes, etc). Even if the server DID know, you still can't call back to the browser and tell it what to do with the page (frame me, don't frame me) with anything but javascript. The javascript is the only script that runs within the context of the browser so that is where you have to query the browser's objects to determine where the page is living and make a determination whether to re-request in a different window or do nothing.
Peter
------------------------------------------------------
Work smarter, not harder.
|
|

December 9th, 2003, 03:45 PM
|
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Peter,
Not exactly. Even with all javascript removed, it still re-draws the screen after first presenting a blank screen, because only on the client side can it interpret the "<%=variable%>".
Your general case javascript is now in my permanent saved code, and it's wonderfully helpful and explanative. In this instance, though, only 1 file name is ever returned on the QueryString and the name is known in advance. If all javascript is removed, interpreting the "<%=variable%>" by the browser causes the flicker.
I learned, correct me here, that javascript works because it can access the DOM. And .NET certainly accesses the DOM. Therefore I suppose that the C# ( VB) code, (which runs on the server, correct me here too) could alter the file name in question in the DOM in XML.
This seems like overkill, the flicker isn't that bad; we'll live with it. But that would work, wouldn't it, and remove the flicker?
With great appreciation,
Sandra MacGregor
|
|

December 9th, 2003, 05:22 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
Let's clarify a few things:
1) "<%=variable%>" is server side. The <%%> denotes server side code. "variable" is only visible within the scope of the executing ASPX. When you do something like this in your page...
var myVar = "<%=variable%>";
You are actually having the server "hardcode" the value into the javascript. The result is:
var myVar = "value from variable";
Take a look at the HTML source, you'll see it in there.
2)
Quote:
|
quote:If all javascript is removed, interpreting the "<%=variable%>" by the browser causes the flicker.
|
Where is the result of <%=variable%> going?
3) Careful about getting your DOMs confused. DOM is "Document Object Model". Many things have DOMs: the browser and XML both use DOMs. When you work with an XML document on the server, you deal with the XML's DOM. When working with javascript in the browser you deal with that browser's DOM (actually, you deal with the DOM of the document that's in the browser's window). Now I'll grant you that HTML (or more correctly XHTML) is XML, but it's XML within the context of the browser not the server.
Think of the browser-server relationship like a carrier pigeon. You tie a note to its leg (HTTP GET/POST) and send it off. Eventually it comes back with a response. That's the extent of the relationship. You can't do anything more than write down instructions about what to send back. Likewise for the other party (the server). All it can do is send its own instructions to you (in the form of HTML and javascript). It's up to the javascript running in the browser to test and determine if more needs to happen.
Peter
|
|

December 9th, 2003, 05:55 PM
|
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
OHHHHHH - - - Different DOMs! I'll think carrier pigeon!
The <%=variable%> is the same one we've been talking about. I;m happy to learn it's server side, but it doesn't act like it.
The source lines in NavFrameset.aspx with the <%=variable%> named forFrame are:
<frameset cols="90,*">
<frame name="Navigator" src="Navigation.htm" borderColor="#000000" style="BACKGROUND-COLOR: #000000">
<frame name="main" src="<%=forFrame%>">
There's no javascript in this file, nor in the files in question.
I've tried to look at the file NavFrameset.aspx when it's running but find I don't know how to access it. All I can viewsource are the files in the frames themselves.
The result of the variable tells the frameset which page to load into the 'main' frame. Since this value is a variable the frameset acts as if it's null at first, although it is assigned a positive value in the C#.NET Page_Load:
private void Page_Load(object sender, System.EventArgs e)
{
// Set the 'default' page
forFrame = "NLELogo.aspx";
// Load NameValueCollection object.
NameValueCollection coll = Request.QueryString;
// Find out if we're returning from a products page to the catalog page by testing the QueryString for empty.
// and if not, rediret it to the Catalog page.
if(coll.Count != 0) {
forFrame = "Catalog.htm";
}
}
(In C# you have to use NameValueCollection instead of string.)
This is all the code involved. You can see the flicker by going to http://www.nolimiteng.com, click on catalog, click on any link, scroll to the bottom of that page, and click on the return link.
You're a great teacher!
Sandra MacGregor
|
|

December 9th, 2003, 06:16 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
Gee, thanks.
You can get at the frameset HTML source by clicking View->Page Source on the IE menu. That will give you the main window page source. As you found, the usual way of right-clicking gives you the source of the frame document.
When looking at this URL:
http://www.nolimit.net/NavFrameset.a...st=Catalog.htm
I got this for the source (minus the <noframes> part):
<frameset cols="90,*">
<frame name="Navigator" src="Navigation.htm" borderColor="#000000" style="BACKGROUND-COLOR: #000000">
<frame name="main" src="Catalog.htm">
</frameset>
This looks like exactly what you want. The "flicker" is not anything you can change. When you "return" to this URL, you are re-requesting the frameset, then requesting the nav (left) and the main page again. That's how the browser works.
Why don't you put the catalog sections in the same frame so you retain the left nav, and then returning only involves returning to the catalog page? That would make the user experience more consistent because you aren't sending them off to another page without the main nav.
Regarding the querystring:
I was originally trying to write that example in C# cause I knew you were using C#, but I don't usually use it so I had some problems and gave up. :(
I solved the problem and redid it but you probably had the first version. Anywho...
You can access querystring values like this:
Request.QueryString.Get("keyname")
That's a little easier than having to deal with the collection object.
Peter
------------------------------------------------------
Work smarter, not harder.
|
|
 |