eriva_br 7 Denunciar post Postado Janeiro 29, 2008 Desativando o botão direito do mouse em navegadores, javascript com chamada pelo C# ou VB OBS.: testado no IE6 e Firefox 1.5 C# chamada: protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.RetirarPropriedades(); } } função: private void RetirarPropriedades() { string cstext = @" var message=''; function clickIE() { if (document.all){ return false; } } function clickNS(e) { if(document.layers||(document.getElementById&&!document.all)){ if(e.which==2||e.which==3) { return false; } } } if (document.layers){ document.captureEvents(Event.MOUSEDOWN); document.onmousedown=clickNS; }else{ document.onmouseup=clickNS; document.oncontextmenu=clickIE; } document.oncontextmenu = new Function('return false'); "; this.Page.ClientScript.RegisterStartupScript(this.GetType(), "RetirarPropriedades", cstext, true); } VB chamada: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If (Not IsPostBack) Then Me.RetirarPropriedades() End If End Sub função: Private Sub RetirarPropriedades() Dim cstext As String = "" cstext &= "var message='';" cstext &= " function clickIE() {" cstext &= " if (document.all){" cstext &= " return false;" cstext &= " }" cstext &= " }" cstext &= " function clickNS(e) {" cstext &= " if(document.layers||(document.getElementById&&!document.all)){" cstext &= " if(e.which==2||e.which==3) {" cstext &= " return false;" cstext &= " }" cstext &= " }" cstext &= " }" cstext &= " if (document.layers){" cstext &= " document.captureEvents(Event.MOUSEDOWN);" cstext &= " document.onmousedown=clickNS;" cstext &= " }else{" cstext &= " document.onmouseup=clickNS;" cstext &= " document.oncontextmenu=clickIE;" cstext &= " }" cstext &= " document.oncontextmenu = new Function('return false'); " Me.Page.ClientScript.RegisterStartupScript(Me.GetType, "RetirarPropriedades", cstext, True) End Sub t+ Compartilhar este post Link para o post Compartilhar em outros sites