This topic is locked
[SOLVED]

 List page tabs

5/2/2018 6:28:49 PM
ASPRunner.NET General questions
jadach authorDevClub member

Does anyone know how to set a specific tab on the list page as active based on a session variable?
Thanks

admin 5/3/2018

When you click a tab URL changes and you can note that URL and make a redirect to that URL in one of events. Just make sure you do not enter redirect loop as page will be reloaded and you will run the same event again.

jadach authorDevClub member 5/3/2018



When you click a tab URL changes and you can note that URL and make a redirect to that URL in one of events. Just make sure you do not enter redirect loop as page will be reloaded and you will run the same event again.


I see. However, my URL is

https://MyDomain.com/dbo_FMSProgram/list?mastertable=dbo.FMS&masterkey1=2&masterkey2=Jenson3


Prior to getting to that list page, I have access to a session variable which will tell me what tab should be active. Somehow I need to append &tab=D1 to then end of that url.

https://MyDomain.com/dbo_FMSProgram/list?mastertable=dbo.FMS&masterkey1=2&masterkey2=Jenson3&tab=D1 or

https://MyDomain.com/dbo_FMSProgram/list?mastertable=dbo.FMS&masterkey1=2&masterkey2=Jenson3&tab=D2 or

https://MyDomain.com/dbo_FMSProgram/list?mastertable=dbo.FMS&masterkey1=2&masterkey2=Jenson3&tab=D3
Pete K 5/3/2018

Just taking a stab here -- could you write code in the BeforeProcessList() event of that page, process the URL and add the desired tab to the end, then do a redirect back to itself with the tab appended? Not sure if that would work but that;s what I would try.

jadach authorDevClub member 5/3/2018



Just taking a stab here -- could you write code in the BeforeProcessList() event of that page, process the URL and add the desired tab to the end, then do a redirect back to itself with the tab appended? Not sure if that would work but that;s what I would try.


I tried something like that, but ended up in an unending loop.
I would love to use JavaScript via proxy to set the appropriate tab to active somehow.

admin 5/3/2018

I think the code flow should as follows

  1. Get the current page URL
  2. Check if "tab" parameter is there already
  3. If not - add it and redirect
    HttpContext.Current.Request.Url.AbsoluteUri - should have the URL in it
    Request.QueryString["tab"] - should give you access to "tab" parameter

jadach authorDevClub member 5/3/2018



I think the code flow should as follows

  1. Get the current page URL
  2. Check if "tab" parameter is there already
  3. If not - add it and redirect
    HttpContext.Current.Request.Url.AbsoluteUri - should have the URL in it
    Request.QueryString["tab"] - should give you access to "tab" parameter


Thanks. I will try that and report back.

jadach authorDevClub member 5/3/2018



I think the code flow should as follows

  1. Get the current page URL
  2. Check if "tab" parameter is there already
  3. If not - add it and redirect
    HttpContext.Current.Request.Url.AbsoluteUri - should have the URL in it
    Request.QueryString["tab"] - should give you access to "tab" parameter


I get the idea, but I am struggling. What event would I do this on?
Thanks

jadach authorDevClub member 5/4/2018

I got it working. Not sure if this is the very best way, but it works well.
List page: Before process - I establish a few session variables.

XSession.Session["NextSession"] = data3["NextSession"].ToString();

XSession.Session["MyPage"] = System.Web.HttpContext.Current.Request.Url.AbsoluteUri;


Then on List page: After record processed - I do the redirect if necessary.

string x = System.Web.HttpContext.Current.Request.Url.AbsoluteUri;

string a = "tab=";

if (x.Contains(a))

{

// ignore

}

else

{

MVCFunctions.HeaderRedirect("" + XSession.Session["MyPage"].ToString() + "" + "&tab=D" + ""+XSession.Session["NextSession"].ToString()+"");

}
Pete K 5/7/2018

deleted