Blocking mouse right click....

V

Veeresh

In my asp.net application I want to block mouse right click on my web pages.
That means instead of popup menu I may just display some message or no
message at all.
Hot to do that?
Thanks,
Veer
 
K

Kevin Spencer

Hot to do that?

Not to do that.

No doubt you want to protect some HTML or images in your pages, right?
Forget it. Any web developer worth his salt know that a browser by
definition DOWNLOADS COPIES of documents, images, etc. Once the user sees
them, a copy already exists on their machine. It can easily be opened in
NotePad from the Temporary Internet Files folder, or viewed in any of a
half-dozen other ways. Only amateurs prevent right-clicking. And you're not
an amateur, right?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
V

Veeresh

No. Thats not correct. I am trying to avoid user accessing Back menu in the
popup menu.
Veer
 
S

Scott Allen

What if they use the Backspace button?

I think Kevin's point is that trying to change the way the client's
browser interface works is almost always a bad idea. If you count on
disabling browser functionality for your application to work, someone
will always find a way around it.
 
V

Veeresh

Thats true. I am looking for options to disable the browser back button
too!!!
I am not finding the proper way through code to make sure after processing
the data in a page and if the use comes back, all posting may happen again.
I think the right way(professional way) is controlling through code.
I have the following code at the page_load event to expire the page once the
user is out of the current page
Response.Expires = 0
'Response.Cache.SetNoStore()

Response.AppendHeader("Pragma", "no-cache")

It seems the page is not getting expired. Really don't know how to solve it.
Veer
 
C

Curt_C [MVP]

you CAN'T....
Fix the code so that the back doesn't break things instead of trying to
adjust the users browser.
 
V

Veeresh

Thats good. I will work on fixing the code. Any suggestions why my below
code is not expiring the page. What I did is added the below code in
page1.aspx and moved to the next page by clciked event of button1 in page1
using response.redirect("page2.aspx"). After hitting browser back button I
am able to navigate back to page1.aspx. I was expecting to get the page
expired message when I hit the browser back button.
Veer
 
A

ashelley

Thats true. I am looking for options to disable the browser back button
too!!!
I am not finding the proper way through code to make sure after processing
the data in a page and if the use comes back, all posting may happen again.
I think the right way(professional way) is controlling through code.
I have the following code at the page_load event to expire the page once the
user is out of the current page
Response.Expires = 0
'Response.Cache.SetNoStore()

On method is using the SmartNavigation option. This make it so when a
user hits the backbutton it will exit your app. There are some
caveats so you will want to research this option and see if it works
for you.

-Adam
 
V

Veeresh

Interesting. I am already using smart navigation in my application. It is
really a nice feauture. But very curious to know how to disable browser
button using Smart Navigation.
Veer
 
V

Veeresh

The following code worked for me.

Response.Cache.SetExpires(DateTime.Now.AddSeconds(0)) '1

Response.Cache.SetCacheability(HttpCacheability.NoCache) '2

Response.Cache.SetValidUntilExpires(False) '3

Response.Cache.VaryByParams("Category") = True '4

Really don't know how it is working. Really don't know the significance of
line 4. If I comment the line 4, the entire logic does not work.

Veer
 
C

Curt_C [MVP]

it doesn't disable the button, it works around it....
Again, dont try to adjust the users settings....ever... This is bad
programming practice, besides the fact that you really cant without being
considered a security risk
 
V

Veeresh

Thanks for suggestions. I will stop thinking on changing the user settings.
Its a good suggestions for me becuase somehow I also convinced that the best
way is to take care in the application coding instead of setting the
browser.
Thanks
Veer
 
K

Kevin Spencer

Its a good suggestions for me becuase somehow I also convinced that the
best
way is to take care in the application coding instead of setting the

Exactly right, Veer.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top