Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 10, 2012 01:56 AM by Young Yang - MSFT
Member
4 Points
15 Posts
Apr 03, 2012 06:33 AM|LINK
Hi,
I have a page(a.aspx) to which im navigating from two different pages(ie there is a link in these two pages where it navigates to a.aspx)
to differentiate from which page i was navigated to a.aspx i used the below code.
passed Querystrings(B1,B2) to the target page as below
Html.ActionLink("test" "Testing", new { Controller = "Stats",prev="B1"},new { @class = "link",target="_self" }) Html.ActionLink("test" "Testing", new { Controller = "Stats",prev="B2"},new { @class = "link",target="_self" })
and in the action of the target page controller i used the below code
ViewData["prev"] = Request.QueryString["prev"].ToString();
and im using this ViewData in the target page ie a.aspx.This is working fine.. Im abit reluctant to use Query.string and ViewData for the above requirement.Please suggest any other alternative approach for the same.
mvc csharp
328 Points
260 Posts
Apr 03, 2012 06:59 AM|LINK
You can change your code above as:
@Html.ActionLink("test", "Testing", "Stats", new { prev = "B1"},new { @class = "link",target="_self" }) @Html.ActionLink("test", "Testing", "Stats", new { prev = "B2"},new { @class = "link",target="_self" })
and your action will be like this:
public ActionResult Testing(string prev) { //You can get prev as parameter }
Apr 03, 2012 07:10 AM|LINK
Thanks for ur reply...
But i do not want to change the action arguments..
Apr 03, 2012 07:23 AM|LINK
What arguments. Can you post action code?
Apr 03, 2012 10:56 AM|LINK
I mean do not want to pass any arguments....
All-Star
21111 Points
1817 Posts
Microsoft
Apr 10, 2012 01:56 AM|LINK
shiva455 I mean do not want to pass any arguments....
Hi
I dont think it is a good idea that not use the querystring.
Regards Young Yang
shiva455
Member
4 Points
15 Posts
Alternative for ViewData and QueryString
Apr 03, 2012 06:33 AM|LINK
Hi,
I have a page(a.aspx) to which im navigating from two different pages(ie there is a link in these two pages where it navigates to a.aspx)
to differentiate from which page i was navigated to a.aspx i used the below code.
passed Querystrings(B1,B2) to the target page as below
Html.ActionLink("test" "Testing", new { Controller = "Stats",prev="B1"},new { @class = "link",target="_self" }) Html.ActionLink("test" "Testing", new { Controller = "Stats",prev="B2"},new { @class = "link",target="_self" })and in the action of the target page controller i used the below code
and im using this ViewData in the target page ie a.aspx.This is working fine.. Im abit reluctant to use Query.string and ViewData for the above requirement.Please suggest any other alternative approach for the same.
mvc csharp
pantonis
Member
328 Points
260 Posts
Re: Alternative for ViewData and QueryString
Apr 03, 2012 06:59 AM|LINK
You can change your code above as:
@Html.ActionLink("test", "Testing", "Stats", new { prev = "B1"},new { @class = "link",target="_self" }) @Html.ActionLink("test", "Testing", "Stats", new { prev = "B2"},new { @class = "link",target="_self" })and your action will be like this:
public ActionResult Testing(string prev) { //You can get prev as parameter }mvc csharp
Please mark this post as answer if it helped you solve your problem
shiva455
Member
4 Points
15 Posts
Re: Alternative for ViewData and QueryString
Apr 03, 2012 07:10 AM|LINK
Thanks for ur reply...
But i do not want to change the action arguments..
pantonis
Member
328 Points
260 Posts
Re: Alternative for ViewData and QueryString
Apr 03, 2012 07:23 AM|LINK
What arguments. Can you post action code?
Please mark this post as answer if it helped you solve your problem
shiva455
Member
4 Points
15 Posts
Re: Alternative for ViewData and QueryString
Apr 03, 2012 10:56 AM|LINK
I mean do not want to pass any arguments....
Young Yang -...
All-Star
21111 Points
1817 Posts
Microsoft
Re: Alternative for ViewData and QueryString
Apr 10, 2012 01:56 AM|LINK
Hi
I dont think it is a good idea that not use the querystring.
Regards
Young Yang
Feedback to us
Develop and promote your apps in Windows Store