TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
maryam it
NA
14
787
How do I pass parameters to another page using ASP.NET friendly URL?
Apr 14 2021 6:59 AM
I'm using asp.net4 on visual studio 2012 and I installed the asp Friendly Url package. in the Article page, I want to redirect to the ArticleDetail page when the user presses the "read more" button and the "articleName" parameter passed to the ArticleDetail page too.
the problem is when I click on the button, the page redirects to the ArticleDetail page and the friendly URL is good(/ArticlesDetails/ArticleName )but when I press on any other link on ArticleDetails page(for example my site menu)it doesn't go on that page(for example homepage) and retain on ArticleDetail and just the URL changed to a wrong URL like "/ArticlesDetails/homepage"
Article.aspx:
protected
void
doc_link_Click1(
object
sender, EventArgs e)
{
Response.RedirectToRoute(
"ArticlesDetails"
,
new
{ articleName=
"TheName"
});
}
ArticleDetail.asp:
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!Page.IsPostBack)
{
var name = Page.RouteData.Values[
"articleName"
];
if
(name!=
null
)
{
switch
(name.ToString())
{
case
(
"TheName"
):
{
//dosomething
break
;
}
default
:
break
;
}
}
}
}
global.asax:
void
Application_Start(
object
sender, EventArgs e)
{
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
RouteConfig.cs:
public
static
class
RouteConfig
{
public
static
void
RegisterRoutes(RouteCollection routes)
{
var settings =
new
FriendlyUrlSettings();
settings.AutoRedirectMode = RedirectMode.Permanent;
routes.EnableFriendlyUrls(settings);
RouteTable.Routes.MapPageRoute(
"Articles"
,
"Articles"
,
"~/Articles.aspx"
);
RouteTable.Routes.MapPageRoute(
"ArticlesDetails"
,
"ArticlesDetails/{articleName}"
,
"~/ArticlesDetails.aspx"
);
}
}
Reply
Answers (
2
)
FileUpload control loses the attactment on every mail send postback.
Cofoundry CMS in Asp.net core.