Thursday, December 6, 2012

EventLog.WriteEntry Error – Requested registry access is not allowed

EventLog.WriteEntry Error – Requested registry access is not allowed
http://iamwanwan.wordpress.com/2011/12/13/eventlog-writeentry-error-requested-registry-access-is-not-allowed/

Write to EventLog using .Net C#
http://limherlina.blogspot.ca/2008/09/write-to-eventlog-using-net-c.html

VS : Writing to the event log FAILED .. Requested registry access is not allowed.
http://zeetalks.wordpress.com/2008/08/16/vs-writing-to-the-event-log-failed-requested-registry-access-is-not-allowed/


http://support.microsoft.com/kb/329291
http://support.microsoft.com/kb/842795

An unhandled exception of type 'System.Security.SecurityException' occurred in mscorlib.dll
Additional information: Requested registry access is not allowed.
 
This problem occurs because the user account that we used to create log does not have sufficient permissions.
 
We can solve the problem by 2 solutions below.

1. Add an application pool on IIS
    Change the default setting of this application pool.
    In Identity tag: change predefined value "Network Service"  to "Local system"
    Set  appMail service app to use this application pool.
 
2. Give the ASP.NET user permission to read from the event log registry entries.
Select Start - Run, then enter: regedt32
Navigate/expand to the following key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Security
Right click on this entry and select Permissions
Add the ASPNET user
Give it Read permission


Wednesday, November 28, 2012

modalpopupextender updateprogress asp.net

http://csharpstepbystep.blogspot.ca/2011/10/aspnet-updateprogress-with.html
http://www.youtube.com/watch?v=_hRs21_dh_s

Javascript--enter key disable

How To: Disable Form Submit on Enter Key Press
http://www.bloggingdeveloper.com/post/Disable-Form-Submit-on-Enter-Key-Press.aspx

The post Enter Key as the Default Button describes how to set the default behaviour for enter key press. However, sometimes, you need to disable form submission on Enter Key press. If you want to prevent it completely, you need to use OnKeyPress handler on <body> tag of your page.

<body OnKeyPress="return disableKeyPress(event)">

<script language="JavaScript">

function disableEnterKey(e)
{
var key;
if(window.event)
key = window.event.keyCode; //IE
else
key = e.which; //firefox

return (key != 13);
}

</script>

If you want to disable form submission when enter key is pressed in an input field, you must use the function above on the OnKeyPress handler of the input field as follows:
<input type=”text” name=”txtInput” onKeyPress=”return disableEnterKey(event)”>

How to disable the Enter key on HTML form

http://webcheatsheet.com/javascript/disable_enter_key.php
Normally when you have a form with several text input fields, it is undesirable that the form gets submitted when the user hits ENTER in a field. Some people are pressing the enter key instead of the tab key to get to the next field. They often do that by accident or because they are accustomed to terminate field input that way. If a browser regards hitting ENTER in a text input field as a request to submit the form immediately, there is no sure way to prevent that.

Add the below script to the <head> section of your page. The following code disables the enter key so that visitors of your web page can only use the tab key to get to the next field.
<script type="text/javascript">

function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}

document.onkeypress = stopRKey;

</script>

Tuesday, October 23, 2012

asp.net anchor

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test.aspx.vb" Inherits="Test" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="Test2.aspx#Link">

        錨點連結至Test2.aspx</asp:HyperLink>

    </div>

    </form>

</body>

</html>



<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test2.aspx.vb" Inherits="Test2" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    第一行<br />
    1<br /><br /><br />
    2<br /><br /><br />
    3<br /><br /><br />
    4<br /><br /><br />
    5<br /><br /><br />
    6<br /><br /><br />
    7<br /><br /><br />
    8<br /><br /><br />
    9<br /><br /><br />
    10<br /><br /><br />
    <a id="Link"></a>
    錨點連結點11<br /><br /><br />
    12<br /><br /><br />
    13<br /><br /><br />
    14<br /><br /><br />
    15<br /><br /><br />
    </div>
    </form>
</body>
</html>