Hi to All,
I developed mobile website.But JavaScript validation not working in mobile browser.Can you please give some idea to support JavaScript in mobile browser.Thanks for Advance.
<%@ Master Language="VB" CodeFile="mAtimsMaster.master.vb" AutoEventWireup="True"
Inherits="Mobile_Source_mAtimsMaster" %>
<%@ Register TagPrefix="Uc1" TagName="RequestPending" Src="~/Mobile/mSource/mUserControls/mRequest/mRequestPending.ascx" %>
<%@ Register TagPrefix="Uc2" TagName="RequestAssigned" Src="~/Mobile/mSource/mUserControls/mRequest/mRequestAssigned.ascx" %>
<!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>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width" initial-scale="1.0;" maximum-scale="1.0;"
user-scalable="0;" />
<meta name="HandheldFriendly" content="true" />
<meta name="MobileOptimized" content="width" />
<link href="../mStyles/mDefault.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function ShowHideMenu() {
var MenuDiv = document.getElementById('MenuDiv');
var menuWidth = $('#MenuDiv').width();
var HeaderSubdiv = document.getElementById('HeaderSubdiv');
var ContentDiv = document.getElementById('DivContent');
var windowwidth = $(window).width();
HeaderSubdiv.style.width = windowwidth + 'px';
ContentDiv.style.width = windowwidth + 'px'
if ($('#MenuDiv').is(':visible')) {
$('#MenuDiv').hide();
HeaderSubdiv.style.width = '99.8%';
ContentDiv.style.width = '99.8%';
}
else {
$('#MenuDiv').show();
var height = $(document).height();
$("#MenuDiv").each(function () {
$(this).css('min-height', height + 'px');
});
menuWidth = menuWidth - 15;
$('.MenuArrowDiv').css('margin-left', menuWidth + 'px');
}
}
</script>
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Path="~/Source/SCRIPTS/jquery191.js" />
<asp:ScriptReference Path="~/Source/SCRIPTS/TextBoxValidate.js" />
<%-- <asp:ScriptReference Path="~/Source/SCRIPTS/IE10Support.js" />--%>
</Scripts>
<div id="IMGDIV" style="display: none; font-family: Verdana, Arial, Helvetica, sans-serif;<br mode=" hold=" /> font-size: 11px; font-style: normal; position: absolute; width: 90%; height: 0%;<br mode=">
<div style="width: 200px; text-align: center; margin: 0 auto;">
<div style="width: 200px; height: 60px; float: left; text-align: center; border-style: inset;<br mode=" hold=" /> border-color: #444468; background-color: #E5F1FF; border-width: 3px; padding-bottom: 5px;">
<div style="width: 180px; height: 45px; float: left; text-align: center; border-style: outset;<br mode=" hold=" /> border-color: #E5F1FF; border-width: 10px;">
<font color="#444468" style="font-family: Times New Roman Baltic; font-size: x-large;<br mode=" hold=" /> font-weight: bold; font-style: italic;">Processing...</font><br />
<asp:Image ID="ldimg" runat="server" ImageUrl="~/Source/Images/LoadingImg.gif" />
</div>
</div>
</div>
</div>
<div id="MaskedDiv" class="MaskedDiv" runat="server" clientidmode="Static">
<div id="WholeDiv" runat="server" clientidmode="Static" class="Page">
<asp:HiddenField ID="HdnWindowWidth" runat="server" />
<div id="MenuDiv" runat="server" clientidmode="Static" style="width: auto; float: left;
background-color: #1f2d3f; display: none;">
<div style="width: auto; float: left; height: auto;">
<div id="MenuTitleDiv" runat="server" style="text-align: center; font-weight: bold;
font-size: medium; color: white; padding: 16px; border-bottom: 1px solid #300;">
ATIMS Mobile Web
</div>
<ul>
<asp:Repeater ID="RptMenu" runat="server" OnItemDataBound="RptMenu_ItemDataBound">
<itemtemplate>
<div id="MenuDivsub" runat="server" style="cursor: pointer; margin-top: 5px; margin-left: -40px;
padding-left: 5px; padding-right: 15px;">
<li id="LiMenu" runat="server" style="list-style-type: none; cursor: pointer; width: auto;
font-size: medium;">
<asp:LinkButton ID="LnkBtnMenu" runat="server" OnClick="LnkBtnMenu_Click" Style="text-decoration: none;">
<asp:HiddenField ID="HdnUrl" runat="server" Value='<%#DataBinder.Eval(Container, "DataItem.UserControl")%>' />
<span>
<div id="DivMenuTitle" runat="server" style="color: white; font-weight: bold; cursor: pointer;
text-decoration: none; vertical-align: middle; padding-left: 5px;">
<asp:Image ID="ImgMenu" runat="server" ImageAlign="AbsMiddle" />
<asp:Literal ID="LtlMenuText" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.MobileWeb_Title")%>'>
</span>
<div id="MenuArrowDiv" runat="server" class="MenuArrowDiv">
<div class="Arrow-Left">
</div>
</itemtemplate>
</ul>
<div id="contentdiv" runat="server" clientidmode="Static" style="overflow: hidden;">
<div style="width: 100%; float: left; height: auto;">
<div id="HeaderDiv" runat="server" clientidmode="Static" style="height: auto; width: 99.8%;">
<div id="HeaderSubdiv" runat="server" clientidmode="Static" style="float: left; width: 100%;
border: 1px solid #300;">
<div id="DivSystemSelect" style="float: left; width: auto; cursor: pointer;" runat="server"
önclick="ShowHideMenu();">
<asp:Image ID="ImgBtnSysSelect" runat="server" ImageUrl="~/Mobile/mImages/mTop_SysSelect.bmp"
ToolTip="System Select" Style="width: auto; height: auto;" />
</div>
<div id="RequestDiv" runat="server" style="width: auto; height: auto; text-align: left;
float: left; padding-top: 3px; padding-left: 3px; padding-right: 3px;">
<div style="width: auto; text-align: left; height: auto;">
<asp:LinkButton ID="LnkBtntPending" runat="server" Text="0 Pending" CssClass="HeaderMessageLink">
</div>
<div style="width: auto; text-align: left; height: auto;">
<asp:LinkButton ID="LnkBtnAssigned" runat="server" Text="0 Assigned" CssClass="HeaderMessageLink">
</div>
<div id="ApplicationNameDiv" runat="server" style="width: auto; height: auto; float: left;">
<div id="ApplnDiv" runat="server" style="width: auto; height: auto; text-align: center;
line-height: 50px; vertical-align: middle; padding-left: 0.3em; position: relative;
margin: 0 auto;">
<asp:Label ID="LblApplication" runat="server" CssClass="HeaderLine1" Text="">
<div id="LogoutDiv" runat="server" style="width: auto; height: auto; float: right;
cursor: pointer;">
<asp:ImageButton ID="ImgBtnLogout" runat="server" ToolTip="Logout" ImageAlign="AbsMiddle"
ImageUrl="~/Mobile/mImages/mLogout.png" Style="cursor: pointer;" />
<div id="HomeDiv" runat="server" style="width: auto; height: auto; float: right;
cursor: pointer;">
<asp:ImageButton ID="ImgBtnHome" runat="server" ToolTip="Go To Home Page" ImageAlign="AbsMiddle"
ImageUrl="~/Mobile/mImages/mTop_Home.bmp" />
<div id="DivPending" runat="server" style="width: 99%; float: left; height: auto;
position: absolute; display: none; background-color: White; border: 2px solid #00264D;">
<Uc1:RequestPending ID="RequestPending1" runat="server" />
<div id="DivAssigned" runat="server" style="width: 99%; height: auto; float: left;
position: absolute; display: none; background-color: White; border: 2px solid #00264D;">
<Uc2:RequestAssigned ID="RequestAssigned1" runat="server" />
<div id="DivContent" runat="server" clientidmode="Static" style="float: left; height: auto;
width: 99.8%;">
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
</form>
</body>
</html>
Code Behind
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI.WebControls
Partial Class Mobile_Source_mAtimsMaster
Inherits System.Web.UI.MasterPage
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
AddHandler RequestAssigned1.AssignedBack, AddressOf HandleAssignedCloseEventIn
AddHandler RequestPending1.PendingBack, AddressOf HandlePendingCloseEventIn
If Not IsPostBack Then
Dim dt As New DataTable
Dim objMobileBL As New BLMobileMaster
dt = objMobileBL.GetApplicationModuleList()
RptMenu.DataSource = dt
RptMenu.DataBind()
If Session("CurrentScreen") <> "" Then
LblApplication.Text = Session("CurrentScreen")
Else
LblApplication.Text = "LandingPage"
End If
End If
If Session("CurrentScreen") IsNot Nothing Then
If RptMenu.Items.Count > 0 Then
For Each menutype As RepeaterItem In RptMenu.Items
Dim DivArrow As HtmlGenericControl = DirectCast(menutype.FindControl("MenuArrowDiv"), HtmlGenericControl)
Dim ListMenu As HtmlGenericControl = DirectCast(menutype.FindControl("LiMenu"), HtmlGenericControl)
Dim getMenuName As Literal = DirectCast(menutype.FindControl("LtlMenuText"), Literal)
ResetStyle(RptMenu)
If Session("CurrentScreen") = getMenuName.Text Then
DivArrow.Style.Add("display", "block")
ListMenu.Attributes.Add("class", "menu-title")
LblApplication.Text = Session("CurrentScreen")
Exit For
End If
Next
End If
End If
CheckRequest()
Catch ex As Exception
Dim ObjBlCommon As New BLCommon : ObjBlCommon.GoToErrorPage(ex)
End Try
End Sub
Protected Sub RptMenu_ItemDataBound(sender As Object, e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles RptMenu.ItemDataBound
Try
If e.Item.ItemType = ListItemType.AlternatingItem OrElse e.Item.ItemType = ListItemType.Item Then
Dim imgMenu As Image = DirectCast(e.Item.FindControl("ImgMenu"), Image)
Dim ltlText As Literal = DirectCast(e.Item.FindControl("LtlMenuText"), Literal)
Select Case (ltlText.Text)
Case "My Settings"
imgMenu.ImageUrl = "~/Mobile/mImages/mMySetting.png"
Case "My Console"
imgMenu.ImageUrl = "~/Mobile/mImages/mMyConsole.png"
Case "Select Console"
imgMenu.ImageUrl = "~/Mobile/mImages/mSelectConsole.png"
Case "My Housing"
imgMenu.ImageUrl = "~/Mobile/mImages/mMyHousing.png"
Case "Select Housing"
imgMenu.ImageUrl = "~/Mobile/mImages/mSelectHousing.png"
Case "My Locations"
imgMenu.ImageUrl = "~/Mobile/mImages/mMyLocation.png"
Case "Search Locations"
imgMenu.ImageUrl = "~/Mobile/mImages/mSearchLocation.png"
Case "My Last Inmate"
imgMenu.ImageUrl = "~/Mobile/mImages/mLastInmate.png"
Case "Search Inmate"
imgMenu.ImageUrl = "~/Mobile/mImages/mSearchInmate.png"
Case "Request Menu"
imgMenu.ImageUrl = "~/Mobile/mImages/mRequestMenu.png"
End Select
End If
Catch ex As Exception
Dim ObjBlCommon As New BLCommon : ObjBlCommon.GoToErrorPage(ex)
End Try
End Sub
Protected Sub LnkBtnMenu_Click(sender As Object, e As System.EventArgs)
Try
Dim LnkBtnMenu As LinkButton = DirectCast(sender, LinkButton)
Dim MenuItem As RepeaterItem = DirectCast(LnkBtnMenu.NamingContainer, RepeaterItem)
Dim DivArrow As HtmlGenericControl = DirectCast(MenuItem.FindControl("MenuArrowDiv"), HtmlGenericControl)
Dim getScreenName As Literal = DirectCast(MenuItem.FindControl("LtlMenuText"), Literal)
Dim HdnFld As HiddenField = DirectCast(MenuItem.FindControl("HdnUrl"), HiddenField)
Dim ListMenu As HtmlGenericControl = DirectCast(MenuItem.FindControl("LiMenu"), HtmlGenericControl)
ResetStyle(RptMenu)
Dim getNavigationUrl As String = HdnFld.Value
Session("CurrentScreen") = getScreenName.Text
Response.Redirect(getNavigationUrl)
Catch ex As Exception
Dim ObjBlCommon As New BLCommon : ObjBlCommon.GoToErrorPage(ex)
End Try
End Sub
Private Sub ResetStyle(RptMenus As Repeater)
Try
If RptMenus.Items.Count > 0 Then
For Each menutype As RepeaterItem In RptMenus.Items
Dim DivArrow As HtmlGenericControl = DirectCast(menutype.FindControl("MenuArrowDiv"), HtmlGenericControl)
Dim ListMenu As HtmlGenericControl = DirectCast(menutype.FindControl("LiMenu"), HtmlGenericControl)
DivArrow.Style.Add("display", "none")
ListMenu.Attributes.Remove("class")
Next
End If
Catch ex As Exception
Dim ObjBlCommon As New BLCommon : ObjBlCommon.GoToErrorPage(ex)
End Try
End Sub
Protected Sub ImgBtnHome_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles ImgBtnHome.Click
Dim objMobileBL As New BLMobileMaster, strPageTitle As String = Nothing, strPageUrl As String = Nothing
Try
Dim dtbl As New DataTable
dtbl = objMobileBL.GetHomePageId(Session("current_user_id"))
Session("Current_HomePage_Id") = dtbl.Rows(0)("Default_Home_AppAo_MobileWeb_Id")
If Session("Current_HomePage_Id") > 0 Then
Dim datatbl As New DataTable
datatbl = objMobileBL.GetHomePageDetails(Session("current_user_id"))
strPageUrl = datatbl.Rows(0)("UserControl")
Session("CurrentScreen") = datatbl.Rows(0)("MobileWeb_Title")
Response.Redirect(strPageUrl, False)
Else
Dim dt As New DataTable
dt = objMobileBL.MySettingsDetails()
strPageTitle = dt.Rows(0)("MobileWeb_Title")
strPageUrl = dt.Rows(0)("UserControl")
Session("CurrentScreen") = strPageTitle
Response.Redirect(strPageUrl, False)
End If
Catch ex As Exception
Dim ObjBlCommon As New BLCommon : ObjBlCommon.GoToErrorPage(ex)
End Try
End Sub
Protected Sub ImgBtnLogout_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles ImgBtnLogout.Click
Try
Dim ObjBLPermission As New BLPermission
ObjBLPermission.PermissionCheck("SubModule", "ACCESS", "LOGOUT CLICK")
Session.Abandon()
Response.Redirect("~/Mobile/mSource/mLogin.aspx", False)
Catch ex As Exception
Dim ObjBlCommon As New BLCommon : ObjBlCommon.GoToErrorPage(ex)
End Try
End Sub
Private Sub CheckRequest()
Dim objBLCommon As New BLCommon : Dim Count As Integer, iAssignedCount As Integer = Nothing
Try
If Session("current_personnel_id") <> "" Then
Count = objBLCommon.LoadRequestAssignedAndPendingCount(Session("current_personnel_id"), "Pending")
End If
LnkBtntPending.Text = CStr(Count) & " Pending"
If Session("current_personnel_id") <> "" Then
iAssignedCount = objBLCommon.LoadRequestAssignedAndPendingCount(Session("current_personnel_id"), "Assigned")
End If
LnkBtnAssigned.Text = CStr(iAssignedCount) & " Assigned"
Catch ex As Exception
objBLCommon.GoToErrorPage(ex)
End Try
End Sub
Protected Sub LnkBtntPending_Click(sender As Object, e As System.EventArgs) Handles LnkBtntPending.Click
DivPending.Style.Add("display", "block")
DivAssigned.Style.Add("display", "none")
RequestPending1.InitializeScreen(Nothing, Nothing, Nothing, Nothing, "Master")
End Sub
Protected Sub LnkBtnAssigned_Click(sender As Object, e As System.EventArgs) Handles LnkBtnAssigned.Click
DivAssigned.Style.Add("display", "block")
DivPending.Style.Add("display", "none")
RequestAssigned1.InitializeScreen(Nothing, Nothing, Nothing, Nothing, "Master")
End Sub
Public Sub HandlePendingCloseEventIn()
Try
DivPending.Style.Add("display", "none")
Catch ex As Exception
Dim objblcommon As New BLCommon : objblcommon.GoToErrorPage(ex)
End Try
End Sub
Public Sub HandleAssignedCloseEventIn()
Try
DivAssigned.Style.Add("display", "none")
Catch ex As Exception
Dim objblcommon As New BLCommon : objblcommon.GoToErrorPage(ex)
End Try
End Sub
End Class
javascript:
function NumberOnly(e, Obj, BoolGrid) {
var ObjCode = (document.all) ? e.keyCode : e.which;
var ObjID = Obj.id; var UCntrlID = ""; var i = 0; var lblErrorID;
var IDArry = ObjID.split("_");
var ErrorObj = document.getElementById('lblErrorMessage')
if (ErrorObj != null) lblErrorID = 'lblErrorMessage';
else {
if (BoolGrid == 'Grid1') {
for (i = 0; i < 5; i++) {
UCntrlID = UCntrlID + IDArry[i] + "_";
}
}
else if (BoolGrid == 'Grid2') {
for (i = 0; i < 3; i++) {
UCntrlID = UCntrlID + IDArry[i] + "_";
}
}
else if (BoolGrid == 'Grid3') {
for (i = 0; i < 2; i++) {
UCntrlID = UCntrlID + IDArry[i] + "_";
}
}
else {
for (i = 0; i < IDArry.length - 1; i++) {
UCntrlID = UCntrlID + IDArry[i] + "_";
}
}
lblErrorID = UCntrlID + 'lblErrorMessage';
}
if (ObjCode >= 48 && ObjCode <= 57 || ObjCode == 32) {
if (document.getElementById(lblErrorID) != null) document.getElementById(lblErrorID).innerHTML = " ";
else if (document.getElementById('lblErrorMessage') != null) document.getElementById('lblErrorMessage').innerHTML = " ";
return true;
}
else {
if (document.getElementById(lblErrorID) != null) document.getElementById(lblErrorID).innerHTML = "Please Enter only numbers";
else if (document.getElementById('lblErrorMessage') != null) document.getElementById('lblErrorMessage').innerHTML = "Please Enter only numbers";
return false;
}
}