CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 12/4/2007 6:05:54 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 4 Views: 41 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
5 Items, 1 Pages 1 |< << Go >> >|
brentlakatos
Asp.Net User
Javascript with Masterpage - Keystroke listener12/4/2007 6:05:54 AM

0/0

Hi,

In a test page I have the following javascript that deletes the text out of a readonly <input type="text" id="Text1"> by listening to the key stroke events.  The javascript is as follows: 

if (typeof window.event != 'undefined')
  document.onkeydown =
function()  {  return (event.keyCode != 8);  }
else
  document.onkeypress = function(e) {  return (e.keyCode != 8);  }

function ListenerControl(oTextbox ) {
this.textbox = oTextbox;
this.init();
}

ListenerControl.prototype.handleKeyUp = function (oEvent) {
var iKeyCode = oEvent.keyCode;
//for backspace (8) and delete (46), shows suggestions without typeahead
if (iKeyCode == 46) { this.textbox.value = ''; }
};

ListenerControl.prototype.init = function () {
var oThis = this;
this.textbox.onkeyup = function (oEvent) {
  if (!oEvent)
  {
    oEvent = window.
event;
  } 
  oThis.handleKeyUp(oEvent);};
};

window.onload = function () {var oTextbox = new ListenerControl(document.getElementById('Text1')); }

/////////////////////////////////////

This javascript works fine in my test page without a masterpage.  When I put the javascript into my page that uses a masterpage I change the last line of script that creates the ListenerControl to:
window.onload = function () {var oTextbox = new ListenerControl(document.getElementById('ctl00$ContentPlaceHolder1$UploadNewComp1$Test1')); }
to use the ClientID of 'Text1'.  But when I run the page I get a Javascript error that says this textbox is null or not an object.

Does anyone have any ideas?  This is driving me crazy as I need to use the masterpage.

Thanks!

somnathmali
Asp.Net User
Re: Javascript with Masterpage - Keystroke listener12/4/2007 7:15:20 AM

0/0

 Window.onload event attachement will not work on Netscape directly ... Go fo following code ..

function myAttachEvent ( object , eventName , eventHanlder )
 {

if(window.addEventListener){ // Mozilla, Netscape, Firefox
object.addEventListener(eventName, eventHanlder , false);
} else { // IE
object.attachEvent(eventName , eventHanlder );
}
 
You need to call this function as 
 myAttachEvent ( window , 'onload' , Your_funcation_name ) ;
 


Somnath Mali
.NET Developer , Pune INDIA.


http://www.fotosplatter.com



http://somnath-ms-dot-net.blogspot.com


Please Mark As Answer If my reply helped you.

MorningZ
Asp.Net User
Re: Javascript with Masterpage - Keystroke listener12/4/2007 2:29:23 PM

0/0

Problem i see with your code:

 document.getElementById('ctl00$ContentPlaceHolder1$UploadNewComp1$Test1'))

The "name" parameter uses "$", and you are getting by "ID", which uses "_", so that line should be

document.getElementById('ctl00_ContentPlaceHolder1_UploadNewComp1_Test1'))
 


"If you make it idiot proof, they'll build a better idiot"
brentlakatos
Asp.Net User
Re: Javascript with Masterpage - Keystroke listener12/4/2007 2:50:45 PM

0/0

Good catch Morningz!

For some reason the other javascript functions that I have for onmouseover and onblur...worked fine with the document.getElementByID( '$'s ), but not for registering the listener. 

Do you know why that is?  I find it wierd that any would work in the first place.

Thanks,

MorningZ
Asp.Net User
Re: Javascript with Masterpage - Keystroke listener12/4/2007 3:06:46 PM

0/0

 all i know is that if you are getting a DOM object by "id", then you should use the id, not the name....

i have absolutely no explanation why it would work any other way


"If you make it idiot proof, they'll build a better idiot"
5 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
Javascript with Masterpage - Keystroke listener - ASP.NET Forums Re: Javascript with Masterpage - Keystroke listener ... Re: Javascript with Masterpage - Keystroke listener ...
From donmontalvo at mac.com Sat Jan 1 18:43:36 2005 From ... Not being a graphics professional, I don't know what keystroke is now used in the ...... to type in formulas (just the JavaScript part would work for me), ...
WilliaBlog.Net - I dream in Code JS file that was added to the header in the master page, but if I - or .... Most of the code is of course JavaScript. Lines 13 to 62 simply create the ...
CLICK HERE! MORE INFORMATION! gridleys barbeque gridview capture keystroke gridview catch esc return key ... gridview textbox value hiddenfield javascript calendar gridview todate gridview total row count ...
WikiVanning - WikiSym wiki, and summarizes the wiki, points to the master page list, etc.,. .... potentially life-time history (graph) eg every keystroke date-stamped downloaded ...
Microsoft SharePoint Products and Technologies Team Blog ... Master pages: A master page is an ASP.NET page that has the file name ...... The first two dialogs show the "listener" and "public name" properties of the ...
Scott Hanselman's Computer Zen - August, 2007 Dave's Quick Search Bar - Written originally in JavaScript and now written in ...... Avoid wasting the listener's time. (and make the commute less boring) ...
-o flag indicateur -o Sun -s flag indicateur -s Sun -s option flag ... Sun keystroke frappe de touche GDT : Action d'appuyer sur une touche de clavier. ..... [L10n_Eng_Confirm_050605] Sun listener écouteur GNOME listener class ...
JSF JavaScript form submit fails in IE7, works in FF and Safari ...... showing records for updating value after click on modify link on masterpage. ...
Dave Crane Eric Pascarello pass in the listener functions, and provide implementations for the listen- ...... define a master page that will include any necessary JavaScript files, ...




Search This Site:










repeater with multiple itemtemplates

some questions about login control

server side <link> switching of css

does anybody have code to sort a dropdown list?

have a problem with variables in the vb codebehind file

what does this code do?

how to change/add default role on register?

module action (3.0.1)

forum problem

making a better content management system (cms)

"view" control type

dnn forums - anonymouse posting?

default.skin does not seem to be being referenced properly

a looking for a 3rd party control that performs file uploads and downloads

server error in '/' application.

using "role" option in web.config

profile provider and the requirements - reality check

why webpartmanager make use of access data base?

count: total lines of code?

search module

how to improve website ranking google

any downside to having more than 1 web worker process for dnn?

mysql and dotnetnuke

3.0.10 user account registration preferences

are web parts right for me ?

system.runtime.interopservices.comexception

vs 2008 open website

menu control office style

pa installation question - group of modules in the same zip

recurring subscriptions

 
All Times Are GMT