This topic is locked
[SOLVED]

 Accessing passed parameter in link issue

7/19/2019 8:07:52 AM
ASPRunner.NET General questions
D
DebZ author

Hello,
I'm successfully formatting background color for rows based on the length of time a task has been open. I wish however, to give the user the opportunity to list/view without any color formatting.

I thought it would be best done by having two menu entries that passed a variable (ptclr) with a value (0 for b/w, 1 for coloring) to the list. The variable is passing correctly, but I have no idea how to access it via the

after record processed event. I tried:
If Params("ptclr") =="1" {

}
But the code would not compile. Do I need to create a session variable? If so, I'm not sure how or which event.
Thanks in advance.
Deb

T
Tim 7/19/2019

Hi Deb,
I assume you are using the "Menu Item Editor", clicking the "..." button and adding 0 or 1 in the "Edit Page Link" text box. If so, this shows up as a query string in the URL, like so:
mysite.com/myapp/mypage/list?ptclr=0
You can access query strings this way:
if (HttpContext.Current.Request.QueryString["ptclr"].ToString() == "0") {

Do Something

}
Good luck!

Tim

D
DebZ author 7/19/2019

Thanks, that almost works. The only issue now is that the list returns many pages worth of data. when you click the (2,3,4, etc...) buttons on the bottom of the page to get the next page, it does not provide the link with the ptclr=x parameter, and so pages 2-xxxx fail.



Hi Deb,
I assume you are using the "Menu Item Editor", clicking the "..." button and adding 0 or 1 in the "Edit Page Link" text box. If so, this shows up as a query string in the URL, like so:
mysite.com/myapp/mypage/list?ptclr=0
You can access query strings this way:
if (HttpContext.Current.Request.QueryString["ptclr"].ToString() == "0") {

Do Something

}
Good luck!

Tim

T
Tim 7/19/2019

Ah yes, that will only be there when you click the link from the menu. What if you put a button at the top of your list page that toggled a session variable? I usually do this by adding 2 buttons and just showing the one that is opposite of how the session is currently set. So something like:
button 1 "View BW"

server code:

XSession.Session["bw"]=1;
button 2 "View Color"

server code:

XSessoin.Session["bw"]=0;
Then show/hide buttons based on how session is set, and also apply background color based on session.
Just a thought.

Tim

D
DebZ author 7/19/2019

OH! That sounds much more elegant. I'm going to give it a try.

I will post my success or failure <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=88243&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
Thanks again,
Deb



Ah yes, that will only be there when you click the link from the menu. What if you put a button at the top of your list page that toggled a session variable? I usually do this by adding 2 buttons and just showing the one that is opposite of how the session is currently set. So something like:
button 1 "View BW"

server code:

XSession.Session["bw"]=1;
button 2 "View Color"

server code:

XSessoin.Session["bw"]=0;
Then show/hide buttons based on how session is set, and also apply background color based on session.
Just a thought.

Tim

D
DebZ author 7/19/2019

This works pretty well. The only 2 items I need to do now are

  1. Figure out how to set the "BW" parameter before they click the button.
  2. The buttons set the variable fine, but I have to manually hit F5 to refresh. Is there a way to refresh the screen from that button?
    Thanks so much, this really made the "report/list" much more interactive.


    Ah yes, that will only be there when you click the link from the menu. What if you put a button at the top of your list page that toggled a session variable? I usually do this by adding 2 buttons and just showing the one that is opposite of how the session is currently set. So something like:
    button 1 "View BW"

    server code:

    XSession.Session["bw"]=1;
    button 2 "View Color"

    server code:

    XSessoin.Session["bw"]=0;
    Then show/hide buttons based on how session is set, and also apply background color based on session.
    Just a thought.

    Tim

D
DebZ author 7/19/2019

I figured out how to refresh.

use a location.reload(); in the client side of the code button.
Now to figure out where to set the BW Session variable to begin with

T
Tim 7/19/2019

How about, on List page, Before display event
if (!XSession.Session["bw"]) {

XSession.Session["bw"]=0;

}

D
DebZ author 7/19/2019

Beautiful! I put it in the "Before Processing" event, the Before display didn't work on the initial load.

Thank you so much!
Woot <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=88247&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />



How about, on List page, Before display event
if (!XSession.Session["bw"]) {

XSession.Session["bw"]=0;

}

T
Tim 7/19/2019

Great stuff! And thank you for the diversion. I was able to procrastinate my work while still feeling like I was accomplishing something! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=88248&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' /> <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=88248&image=2&table=forumreplies' class='bbc_emoticon' alt=':D' />
Take care,

Tim