2
\$\begingroup\$

I've got a 'menu' within a Master page which include a number of image buttons with click events.

Within each click event, I want to redirect the user to a specific page. However, if the user is already on the correct page, I don't want to refresh the page.

In the example below, if the user is already on browse.aspx, I don't want to refresh it, however, otherwise I want to redirect the user to browse.aspx.

Is the following code the best way to go about this?

protected void ibtnBrowse_Click(object sender, ImageClickEventArgs e)
{
 if (!Request.Url.Segments[1].ToString().Equals("browse.aspx"))
 {
 Response.Redirect("~/browse.aspx");
 }
}
Jamal
35.2k13 gold badges134 silver badges238 bronze badges
asked Aug 14, 2014 at 14:15
\$\endgroup\$
0

1 Answer 1

3
\$\begingroup\$

I don't think you should do this. When I click a button, it should do something, when it doesn't do anything, it's confusing.

So, when the user clicks on something that is supposed to take him to the page they're already on, it should refresh the page.

For example, Stack Exchange does this: try clicking on the question title here, or on the site name on the main page.

answered Aug 14, 2014 at 15:51
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.