Connecting Tech Pros Worldwide Help | Site Map

Reading blocks..

Newbie
 
Join Date: Dec 2008
Posts: 27
#1: Feb 21 '09
Hey all!

Is it possible to read blocks of a .asp file in that way that my page have the following three fields:

hey.asp:
ptitel="hej"
pbody="yeah"
pbottom="you read this.."

So i wanna read the line with ptitel in default.asp much like Server.Execute("hey.asp?read=ptitel")

I know Server.Execute wont work.. Is there another way?

Thanks!
Frederik
jenkinsloveschicken's Avatar
Member
 
Join Date: Dec 2006
Posts: 56
#2: Feb 22 '09

re: Reading blocks..


Pheddy,

I know I'm late here, but if you are still looking for resolution, perhaps this will help. You can use GET or POST variables in the page to create condition filters like so-

hey.asp?view=1

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim int_userView As Integer
  3.  
  4. '''Set int_userView = GET variable value
  5. int_userView = Request.QueryString("view")
  6.  
  7. Switch Case int_userView
  8.  
  9.    Case 1
  10.        ptitel="hej"
  11.    Case 2
  12.        body="yeah"
  13.    Case 3 
  14.        pbottom="you read this.."
  15.  
  16. End Select
  17.  
  18. %>
  19.  
  20.  
That's one overly simplistic example. If you are using asynchronus calls(AJAX) to retrieve and re-draw UI components, you may look at XML as an option if your content is static(non-database or user event driven).

Cheers,
Jenkins
Newbie
 
Join Date: Dec 2008
Posts: 27
#3: Feb 22 '09

re: Reading blocks..


Thanks i will try that!
It was supposed to work so that I could have one file with three or more textfields easily loaded with Response.Write somefile.asp?something=something . In this way it would be easy to edit and whatnot..
jenkinsloveschicken's Avatar
Member
 
Join Date: Dec 2006
Posts: 56
#4: Feb 22 '09

re: Reading blocks..


Cool deal. Let me know if that works. If not, give me some more specifics on what you want and we can work towards a more definitive resolution.

Cheers,
Jenkins
Newbie
 
Join Date: Dec 2008
Posts: 27
#5: Feb 22 '09

re: Reading blocks..


It dosnt work..
The basics here are that I cant load a file for Response.Write with the arguments of somefile.asp?something=something (ie: Response.Write somefile.asp?something=something.) Or simply call the characters in that file directly by using Server.Exeucute("somefile.asp") and narrow down the line by Server.Execute("somefile.asp?something=something") .. I could use database or ReadLine arguments.. (The readline has the limit it only reads one line, therefor not usable if the character goes beyond 250 or so.)

Just wanted to now if this was possible in some way, because it would be easier for me to write ONE file with three arguments. But I quess ill go for the db way or have three different files with each its characters..

Thanks anyway :D
jenkinsloveschicken's Avatar
Member
 
Join Date: Dec 2006
Posts: 56
#6: Feb 22 '09

re: Reading blocks..


I'm puzzled now. You could certainly do something like this:


Expand|Select|Wrap|Line Numbers
  1.  
  2. Response.Write "<a href='yoururlhere.asp?urRequestVariableHere=Yourvalue'>Text Name of Link </a>"
  3.  
  4.  
You could do this programmatically and build all components of the href via asp.

It also seems like you might be wanting to make asynchronous calls from what you've described. Are you essentially building the page(HTML) dependent on a user selection?

Another option would be to write out simple tab delimited text files and use FSO to read them.

Give me some more examples of what you are trying to do. DB is a good way to go. But you might easily accomplish the same thing with an XML object and AJAX, then use DHTML to rebuild the DOM. (I am fairly well versed in JS, so if that's the way you need to go, it's no problem.)

Are you trying to make some sort of RSS style story feed?


Let me know if you would like further assistance.

Cheers,
Jenkins
Newbie
 
Join Date: Dec 2008
Posts: 27
#7: Feb 22 '09

re: Reading blocks..


Hi..

Nah Jenkins your all wrong.. I wanted to print/display a line from another document. The only way I know off this is by using the Server.Execute("") This displays all character/the whole document. But I thought there might be a way to display precoded blocks from this document by defining a query, but Server.Execute cant send query strings.. Anyway i rounded this problem by using a database..

Thanks all.
(Oh and should there be anyone who has a lead on this, pls post.)


Frederik.
jenkinsloveschicken's Avatar
Member
 
Join Date: Dec 2006
Posts: 56
#8: Feb 22 '09

re: Reading blocks..


I think I see now. Sorry I wasn't able to help. On last stab(not on a machine with IIS to test, but in theory will work)

Expand|Select|Wrap|Line Numbers
  1.  
  2. <% Your session control here %>
  3.  
  4. <html>
  5. <head>
  6. <title>Defaut Non-Customized Title</title>
  7.  
  8. <script type="text/javascript">
  9. function initiatePage(myuserIdentifier)
  10. {
  11.     var queryString = myuserIdentifier;
  12.     //Your cross browser XML try/catch here
  13.     //innerHTML is used here for simplicity. innerXML may be a better solution 
  14.     //depending on application req
  15.     //You don't have to use asp. you could create a small decision control 
  16.     //via js and direct your calls that way. Receiving files just need to draw html markup or feed text(such as the title)
  17.     if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
  18.     {
  19.  
  20.         //Your asp file would write out the desired title via response.write
  21.                 document.title = xmlHttp.ResponseText;    
  22.  
  23.     }        
  24.  
  25.     xmlHttp.open("GET","yourAspScript.asp"+queryString,true);
  26.         xmlHttp.send(null);
  27.  
  28.  
  29.     //Your next ajax call to build the body via ResponseText or ResponseXML
  30.         //Your receiving asp page could build the div and even handle the db queries
  31.         if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
  32.     {
  33.  
  34.         //Your asp file would write out the desired html markup
  35.                var divControl1 = document.getElementById("customDiv1");
  36.                 divControl1.innerHTML = xmlHttp.ResponseText;    
  37.  
  38.     }
  39.  
  40.        xmlHttp.open("GET","yourAspScript.asp"+queryString+"&pageSection=body",true);
  41.         xmlHttp.send(null);
  42.  
  43. }
  44.  
  45. </script>
  46.  
  47. </head>
  48.  
  49. <%
  50.  
  51. Response.Write "<body onLoad='initiatePage(" & yourSessionPageControlVar & ");'>"
  52.  
  53. Response.Write "<div class='myCSSControl' id='customDiv1' name='customDivSet'></div>"
  54. Response.Write "<div class='myCSSControl' id='customDiv2' name='customDivSet'></div>"
  55. Response.Write "<div class='myCSSControl' id='customDiv2' name='customDivSet'></div>"
  56.  
  57. Response.Write "</body>"
  58.  
  59. %>
  60.  
  61. </html>
  62.  
  63.  
Only limit on querystring length is what the browser is capable of sending via a GET string. If the limit is hit, the POST method could be invoked in the AJAX call to get around that(delimit arrays with "," or something, then use split in asp to create control arrays if needed). So you can use many differentiating variables to determine what content is returned from the XML object.

Essentially you could build a controller that onload calls the conditional page draw(which could be one script that may include db calls if necessary). Then you have two files as document content control.

Best of luck sir,
Jenkins
Newbie
 
Join Date: Dec 2008
Posts: 27
#9: Feb 23 '09

re: Reading blocks..


Thanks Jenkins! Nice :D
jenkinsloveschicken's Avatar
Member
 
Join Date: Dec 2006
Posts: 56
#10: Feb 23 '09

re: Reading blocks..


Glad you like! If you go that route and need any assistance, feel free to let me know and I will assist.
Reply