I had posted an article for using the javascript within master page in asp.net 4.0.
you can view it here http://dandeng.blogspot.com/2011/09/calling-javascript-function-in-aspnet.html
in the artilce i have shown you how to use javascript to fill the user name and password field in the login page. however i still encouter a new issue. the button event never got fired as a result the login page can't be redirect. i use the firebug to step through the javascript code. the button click event did trigger however. the form never had been submit.
the root cause of this issue is the button click event had been handled by another javascript function
ActionOnClick
<button style="vertical-align:top;text-align:center;overflow:hidden;padding:0px;width:65px;height:21px;" onmousedown="childNodes[0].src='Sci_images/Loginbt.jpg';PushButtonPicAlign(this,4,0,100,'MainContent_TopScreen__nlctl111_Image');PushButtonOffsetImage(this,1);" type="button" onfocus="GotFocus("MainContent_TopScreen__nlctl111");" onblur="LostFocus();" onclick="ActionOnClick("MainContent_TopScreen__nlctl111");" onmouseover="childNodes[0].src='Sci_images/Loginbt.jpg';PushButtonPicAlign(this,4,0,100,'MainContent_TopScreen__nlctl111_Image');" onmouseup="childNodes[0].src='Sci_images/Loginbt.jpg';PushButtonPicAlign(this,4,0,100,'MainContent_TopScreen__nlctl111_Image');PushButtonOffsetImage(this,0);" onmouseout="childNodes[0].src='Sci_images/Loginbt.jpg';PushButtonPicAlign(this,4,0,100,'MainContent_TopScreen__nlctl111_Image');PushButtonOffsetImage(this,0);" tabindex="6" id="MainContent_TopScreen__nlctl111"><img style="left: -4px; top: 0px; position: absolute; clip: rect(auto, 68px, auto, 5px);" src="Sci_images/Loginbt.jpg" onload="ImagePicSaveOrigSize(document.getElementById('MainContent_TopScreen__nlctl111_Image'));PushButtonPicAlign(document.getElementById('MainContent_TopScreen__nlctl111'),4,0,100,'MainContent_TopScreen__nlctl111_Image');" id="MainContent_TopScreen__nlctl111_Image" lowsrc="72,21"><span style="font-size: 8pt; vertical-align: top; left: 0px; top: 0px;"></span></button>
the solution is simple and straight you can just call this function within your custom function. then the button click will be triggered and page will be reload and redirect.
put the following code snippet into your own javascript function.
ActionOnClick("BUTTON_ID");
then the auto login will work properly.
No comments:
Post a Comment