<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>ASP.NET</title>
        <link>http://geekswithblogs.net/GertVerhoeven/category/6628.aspx</link>
        <description>ASP.NET</description>
        <language>nl-BE</language>
        <copyright>Gert Verhoeven</copyright>
        <managingEditor>gert.verhoeven78@telenet.be</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>ASP.NET : Disable Left Click But Enable Right Click </title>
            <link>http://geekswithblogs.net/GertVerhoeven/archive/2007/05/16/112519.aspx</link>
            <description>&lt;p&gt;&lt;font size="2"&gt;Sometimes in your web application you will have a link to a file on the server.  Problems occur when the user clicks on the link and opens the file in the browser.  If the user wants to save the file he will get an error.  To force the user to dowload the file you can disable the left click but keep right clicking enabled.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;To make the script accessible on all web pages I declared the script in the &lt;font color="#ff0000"&gt;default.aspx&lt;/font&gt; file&lt;/font&gt;&lt;/p&gt;
&lt;p dir="ltr" style="MARGIN-RIGHT: 0px"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#800000"&gt;head&lt;/font&gt; &lt;font color="#ff0000"&gt;id&lt;/font&gt;&lt;font color="#0000ff"&gt;="Head"&lt;/font&gt; &lt;font color="#ff0000"&gt;runat&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;="server"&amp;gt;&lt;br /&gt;
&lt;/font&gt;&lt;font color="#0000ff"&gt;  &amp;lt;&lt;/font&gt;&lt;font color="#800000"&gt;script&lt;/font&gt; &lt;font color="#ff0000"&gt;language&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;="javascript"&amp;gt;&lt;br /&gt;
    function&lt;/font&gt; noLeftClick() &lt;br /&gt;
    {&lt;br /&gt;
&lt;font color="#0000ff"&gt;      if&lt;/font&gt; (&lt;font color="#0000ff"&gt;event&lt;/font&gt;.button==1)&lt;br /&gt;
      {&lt;br /&gt;
        alert(&lt;font color="#800000"&gt;'Please use the rightclick \"Save Target As\" Command to Download'&lt;/font&gt;)&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
&lt;font color="#0000ff"&gt;  &amp;lt;/&lt;/font&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;br /&gt;
&amp;lt;/&lt;/font&gt;&lt;font color="#800000"&gt;head&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p dir="ltr" style="MARGIN-RIGHT: 0px"&gt;&lt;font color="#0000ff"&gt;&lt;font color="#000000" size="2"&gt;In the html content you have to add the call to the javascript :&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p dir="ltr" style="MARGIN-RIGHT: 0px"&gt;&lt;font color="#000000" size="2"&gt;&amp;lt;a href=&lt;/font&gt;&lt;a target="_blank" rel="nofollow" href="http://www.cnn.com%22/"&gt;&lt;font color="#000000" size="2"&gt;http://server.filename.xls&lt;/font&gt;&lt;/a&gt;&lt;font color="#000000" size="2"&gt; &lt;font color="#0000ff"&gt;onMouseOver='document.onmousedown=noLeftClick' onMouseOut='document.onmousedown=null'&lt;/font&gt;&amp;gt;filename&amp;lt;/a&amp;gt;&lt;/font&gt;&lt;/p&gt;
&lt;p dir="ltr" style="MARGIN-RIGHT: 0px"&gt;&lt;font color="#0000ff"&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt; As you see, you can right click and save the target as, but you can not directly click on it.&lt;/font&gt;&lt;br /&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=112519"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=112519" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/GertVerhoeven/aggbug/112519.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Gert Verhoeven</dc:creator>
            <guid>http://geekswithblogs.net/GertVerhoeven/archive/2007/05/16/112519.aspx</guid>
            <pubDate>Wed, 16 May 2007 07:11:59 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/GertVerhoeven/comments/112519.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/GertVerhoeven/archive/2007/05/16/112519.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/GertVerhoeven/comments/commentRss/112519.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/GertVerhoeven/services/trackbacks/112519.aspx</trackback:ping>
        </item>
    </channel>
</rss>