I have approximately 10 to 12 JavaScript functions that I need to use. Specifically, I want to call 2 or 3 of these functions when certain events occur, such as control changes, focus shifts, and other related actions triggered by the functions themselves.
All these functions are intended for a virtual keypad feature. My goal is to incorporate this virtual keypad onto the master page, where I have already constructed it using HTML forms with JavaScript.
The virtual keypad operates smoothly on the master page; however, it only functions correctly with basic HTML controls that do not include the "runat='server'" attribute. The issue arises when I try to implement the virtual keypad with server-side controls—it fails to work under these circumstances.
I am uncertain about how to execute these functions from content or child pages.
Below is an excerpt of my code:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage2.master.cs" Inherits="MasterPage2" %>
<!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 id="Head1" runat="server">
<title></title>
<script language="javascript" type="text/javascript">
function setId(el) {
id = el;
//alert(el);
document.getElementById(id).focus();
reset();
return 0;
}
function restoreCode(evt) {
ButtonUp(kcode);
}
function writeKeyPressed(evt) {
InsertChar('k', kcode);
return false;
};
function InsertChar(mode, c) {
document.getElementById(id).focus();
}
function ButtonDown(c) {
reset();
}
function ButtonUp(c) {
//codes
resets();
}
function Shift() {
//codes
}
</script>
When calling these functions from a content page with standard HTML controls (without the runat="server"
attribute), they operate effectively.
<input id="txt_pwd" type="password" onfocus="setId('txt_pwd');" />
However, attempting to use them with ASP controls on a content page (containing the runat="server"
attribute) leads to their failure.
<input id="txt_pwd" type="password" onfocus="setId('txt_pwd');" runat="server" />
If anyone can provide a solution for enabling server-side control access to the functions located on the master page, I would greatly appreciate it.