![enter image description here][1]I'm trying to troubleshoot this problem. I created a basic asp page with Javascript in one server which works fine at the moment but when I move the asp page and all the related files to the new server it does not work. What my asp page does is ask for last or first name in text box and it has button which after it is press it returns all the matches with contact info. from Microsoft Access database.
HTML :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<!-- JQuery Library used so that phone_dir.js can use JQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<title>Corporate Phone Directory</title>
</head>
<body bgcolor="#FFFFFF" link="#003399">
<br>
<br>
<div style="font-size: 16px; font-family: Arial; color:#D6D6D6;">
<table width="745" height="81" border="0" align="left" bordercolor="#003399">
<tr>
<td width="300" height="50" align="left" valign="top">
<div align="left" valign="bottom">
Search by either First or Last Name:
<br>
<br>
<input name="Search" type="text" id="Search" value="">
<input name="btnFind2" type="button" id="btnFind2" value="Find" onClick="searchphonedirectory()">
</div>
</table>
</div>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<hr>
<div style="font-size: 16px; font-family: Arial; color:#D6D6D6;" align="left" id='results'>
<!-- Your results will go here -->
</div>
</body>
</html>
Javascript :
$(document).ready(function()
{
$( "#Search" ).keypress(function()
{
if(event.keyCode==13)
{
$("#btnFind2").click();
}; // End of If key code = Enter function
});
});
function searchphonedirectory()
{
var searchentry = document.getElementById('search').value;
if (window.XMLHttpRequest)
{
xmlhttp2=new XMLHttpRequest();
}
else
{
xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp2.onreadystatechange=function()
{
if (xmlhttp2.readyState==4)
{
document.getElementById("results").innerHTML = xmlhttp2.responseText;
}
}
xmlhttp2.open("GET","phoneResults.asp?searchentry="+searchentry,true);
xmlhttp2.send();
};
Other Code which generates the results.
<!--#include file="ASPFiles/phoneDirectory.asp" -->
<%
response.expires=-1
err.clear
on error resume next
'*----------------------------------------------------------------
searchentry = request.querystring("searchentry")
'*----------------------------------------------------------------
sql = "SELECT PhoneDirectory.Name, PhoneDirectory.[Phone#], PhoneDirectory.OfficeExtension,
PhoneDirectory.[Mobile#] "
sql = sql +"FROM PhoneDirectory "
sql = sql +"WHERE (PhoneDirectory.LastName Like '" & searchentry & "%' OR
PhoneDirectory.FirstName Like '" & searchentry & "%' ) "
sql = sql + "ORDER BY LASTNAME,FIRSTNAME"
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn
'response.write(sql)
response.write("<table>")
response.write("<td width='22%' align='left' height='29'>Name</th>")
response.write("<td width='11%' align='left' >Phone</th>")
response.write("<td width='1%' align='left' >Ext</th>")
response.write("<td width='12%' align='left' >Mobile</th>")
response.write("</tr>")
do until rs.EOF
response.write("<tr>")
for each x in rs.Fields
response.write("<td align='left' >" & x.value & "</td>")
next
rs.MoveNext
response.write("</tr>")
loop
response.write("</table>")
%>
This one opens the database:
<%
' FileName="Connection_odbc_conn_dsn.htm"
' Type="ADO"
' DesigntimeType="ADO"
' HTTP="true"
' Catalog=""
' Schema=""
'Dim MM_phoneDirectory_STRING
'MM_phoneDirectory_STRING = "dsn=PhoneDB;"
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
'TESTING DB
conn.Open(Server.Mappath("/webs/corporatenet2/databases/Phone_Directory.mdb"))
%>
First thing is you missed to mention the event" in keypress event and remove the searchphonedirectory() function from HTML input "onClick",
<input name="btnFind2" type="button" id="btnFind2" value="Find">
Add it to your javascript code like this.
$( "#Search" ).keypress(function(event)
{
if(event.keyCode==13)
{
searchphonedirectory();
}; // End of If key code = Enter function
}); //End of Search Keypress Function
hope it helps.
This may not be an answer, but it will certainly help you in the right direction, if the problem is ASP based.
On the root of your web server (\inetpub\wwwroot), create a folder called errors. In that folder create a file called error.asp and paste the following into it...
<%Option Explicit%>
<%
dim LOGON_USER
LOGON_USER = UCASE(Request.ServerVariables ("LOGON_USER"))
PATH = request.ServerVariables("PATH_TRANSLATED")
Const lngMaxFormBytes = 2000
Dim objASPError, blnErrorWritten, strServername, strServerIP, strRemoteIP
Dim strMethod, lngPos, datNow, strQueryString, strURL,PATH
Dim arrError,i
If Response.Buffer Then
Response.Clear
Response.Status = "500 Internal Server Error"
Response.ContentType = "text/html"
Response.Expires = 0
End If
Set objASPError = Server.GetLastError
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>eDischarge encountered an error...</title>
<meta http-equiv="Content-Type" content="text-html; charset=Windows-1252">
<link href="includes\stylesheet.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
html {
font-family: Arial, Helvetica, sans-serif;
}
html body {
font-family: Arial, Helvetica, sans-serif;
}
body {
font-family: Arial, Helvetica, sans-serif;
color: #330000;
margin: 0;
padding: 0;
}
p {
font-size: 90%;
}
.errortitle {
font-family: Arial, Helvetica, sans-serif;
color: white;
font-size: 150%;
font-weight: bold;
width: 100%;
background-color: #770000;
padding: 1em;
}
.errorbody {
padding: 2em;
background: url(http://stas35/errors/images/error.gif) no-repeat top left;
}
.errormessage {
border-left: 10px solid #770000;
padding: 0 0 0 1em;
margin-left: 2em;
color: #770000;
}
.errorpadleft {
padding-left: 2em;
}
-->
</style>
</head>
<%
strError = strError & "<p><strong>Error Type:</strong></p>"
strError = strError & "<p class=""errorpadleft"">" & Server.HTMLEncode(objASPError.Category) & "</p>"
If objASPError.ASPCode > "" Then
strError = strError & "<p class=""errorpadleft"">" & Server.HTMLEncode(", " & objASPError.ASPCode) & "</p>"
end if
strError = strError & "<p class=""errorpadleft"">" & Server.HTMLEncode(" (0x" & Hex(objASPError.Number) & ")" ) & "</p>"
If objASPError.ASPDescription > "" Then
strError = strError & Server.HTMLEncode(objASPError.ASPDescription) & "<br/>"
elseIF (objASPError.Description > "") Then
strError = strError & "<p class=""errorpadleft"">" & Server.HTMLEncode(objASPError.Description) & "</p>"
end if
blnErrorWritten = False
' Only show the Source if it is available and the request is from the same machine as IIS
If objASPError.Source > "" Then
strServername = LCase(Request.ServerVariables("SERVER_NAME"))
strServerIP = Request.ServerVariables("LOCAL_ADDR")
strRemoteIP = Request.ServerVariables("REMOTE_ADDR")
If (strServername = "localhost" Or strServerIP = strRemoteIP) And objASPError.File <> "?" Then
strError = strError & "<p class=""errorpadleft"">" & Server.HTMLEncode(objASPError.File)
If objASPError.Line > 0 Then
strError = strError & ", line " & objASPError.Line
end if
If objASPError.Column > 0 Then
strError = strError & ", column " & objASPError.Column
end if
strError = strError & "</p>"
strError = strError & "<p class=""errorpadleft"">" & Server.HTMLEncode(objASPError.Source) & "</p>"
If objASPError.Column > 0 Then strError = strError & "<p class=""errorpadleft"">" & String((objASPError.Column - 1), "-") & "</p>"
blnErrorWritten = True
End If
End If
If Not blnErrorWritten And objASPError.File <> "?" Then
strError =strError & "<p class=""errorpadleft"">" & Server.HTMLEncode( objASPError.File)
If objASPError.Line > 0 Then
strError =strError & Server.HTMLEncode(", line " & objASPError.Line)
end if
If objASPError.Column > 0 Then
strError =strError & ", column " & objASPError.Column
end if
strError = strError & "</p>"
End If
strError = strError & "<p><strong>Browser Type:</strong></p>"
strError = strError & "<p class=""errorpadleft"">" & Server.HTMLEncode(Request.ServerVariables("HTTP_USER_AGENT")) & "</p>"
strMethod = Request.ServerVariables("REQUEST_METHOD")
If strMethod = "POST" Then
strError =strError & "<p class=""errorpadleft"">POST Data: (" & Request.TotalBytes & " bytes "
If lngPos > 1 Then strError =strError & "?" & Server.HTMLEncode(Left(Request.QueryString, (lngPos - 1)))
strError =strError & ")</p>"
arrError = split(Request.Form,"&")
For i = LBound(arrError) To UBound(arrError)
strError =strError & "<p>" & Server.HTMLEncode(arrError(i)) & "</p>"
Next
End If
strError = strError & _
"<p>" & _
"<strong>User Logon: </strong>" & LOGON_USER & "<br/>" & _
"<strong>User IP: </strong>" & Request.ServerVariables ("REMOTE_ADDR") & "<strong><br/>" & _
"Time: </strong>" & Now() & _
"</p>"
SendMail email_from,email_to,system_name &" 500-100 Error " & LOGON_USER,"<HTML>" & PATH & "<BR><BR>" & replace(strError,"%2F","/") & "</HTML>" ,2
%>
<body>
<div class="errortitle">Your system has encountered an error...</div>
<div class="errorbody">
<div class="errormessage"><%=strError%></div>
</div>
</body>
</html>
Now, in IIS, navigate to the Custom Erros section and scroll down to the 500 error. Edit... this error and select URL as the Message Type. In the URL box, beneath, type /errors/error.asp (remember that the folder should be on the root of your web server [this is usually <drive>\Inetpub\wwwroot] - if you choose to put it elsewhere then this won't work until you resolve the path).
Now try running your pages again and see if you get any ASP error messages. Your page should be redirected to the error.asp page if there is an error.
(Let me know if there are any errors with the code above - I had to mod it on the fly and haven't had chance to test it).
Related
I am working on a form page which has a two sided multiple select boxes. Box 1 will load from the server all the available dates. When double clicked or select and click >, box 1 options will move to box 2. Box 2 options will be highlighted and selected.
During saved, I added no.selected = true in one of the javascript code to select all the options in box 2 and save it.
But when I enter the page during edit mode, I have some problems:
1. When the page loads, all the selected options will be loaded and highlighted in Box 2. I have to pre-select them by again adding selected=’selected’ in the option tag. This will keep them selected so that when I hit update, I will manage to get their values and update the records according.
2. But when I hit transfer a single option from box 2 back to box 1, everything is selected and highlighted in box 1 and box 2, is there a way to not select things in box?
3. I don’t mind box 2 to always remain selected but is there a CSS or something to hide the selected highlights?
4. During save and update, I need the server to manage to request the values from the options tag in box2. What I did is request all the values in a long string, and split it and save. If the options is not selected, I can’t manage to get the values. Again, how to let the options remain selected when moving from Box 1 to Box 2?
5. Double click once and it will select all in box 1? Please see
Double click highlight Box1 issue.
6. Move back or transfer back it will again highlight in dark grey in box 1? Please see Transfer back highlight Box 1 issue
To all the gurus, please help me, thank you very much.
<%
sHOL_ID= request("txtHOL_ID")
iPage = request("Page")
sSearch = request("txtSearch")
sModeSub = request("sub")
if sHOL_ID <> "" then
sID = sHOL_ID
else
sID = UCase(reqForm("txtID"))
end if
sName= reqForm("txtName")
sMainURL = "tmholcal.asp?"
sAddURL = "txtSearch=" & server.HTMLEncode(sSearch) & "&Page=" & iPage
if sModeSub = "up" then
arr=Split(reqform("ToLB"),",")
if Ubound(arr) < 0 then
response.write "<script language='javascript'>"
response.write "if (confirm(""Emptying the selected box will delete the Holiday Calendar Code"")==0)"
response.write " {window.history.back();}"
response.write "</script>"
end if
sSQL = "delete from TMHOL1 where HOL_ID = '" & sID & "'"
conn.execute sSQL
for j = 0 to Ubound(arr)
sDt_Hol = arr(j)
j = j + 1
sPart = arr(j)
sSQL = "insert into tmhol1 (HOL_ID,NAME,DT_HOL,PART,USER_ID,DATETIME) "
sSQL = sSQL & "values ("
sSQL = sSQL & "'" & pRTIN(sID) & "',"
sSQL = sSQL & "'" & pRTIN(sName) & "',"
sSQL = sSQL & "'" & fdate2(sDt_Hol) & "',"
sSQL = sSQL & "'" & pRTIN(sPart) & "',"
sSQL = sSQL & "'" & session("USERNAME") & "',"
sSQL = sSQL & "'" & fdatetime2(Now()) & "'"
sSQL = sSQL & ") "
conn.execute sSQL
Next
sAddURL = "txtSearch=" & sSearch & "&Page=" & iPage
call confirmBox("Update Successful!", sMainURL&sAddURL&"&txtHOL_ID=" & sID & "")
elseif sModeSub = "save" then
if sID = "" then
alertbox(" Holiday Calendar Code cannot be empty! ")
end if
arr=Split(reqform("ToLB"),",")
for i = 0 to Ubound(arr)
sDt_Hol = arr(i)
i = i + 1
sPart = arr(i)
sSQL = "insert into tmhol1 (HOL_ID,NAME,DT_HOL,PART,USER_ID,DATETIME) "
sSQL = sSQL & "values ("
sSQL = sSQL & "'" & pRTIN(sID) & "',"
sSQL = sSQL & "'" & pRTIN(sName) & "',"
sSQL = sSQL & "'" & fdate2(sDt_Hol) & "',"
sSQL = sSQL & "'" & pRTIN(sPart) & "',"
sSQL = sSQL & "'" & session("USERNAME") & "',"
sSQL = sSQL & "'" & fdatetime2(Now()) & "'"
sSQL = sSQL & ") "
conn.execute sSQL
call confirmBox("Save Successful!", sMainURL&sAddURL&"&txtHOL_ID=" & sID & "")
next
end if
function ShowAvailDates(sParam)
Set rs=server.CreateObject("ADODB.Recordset")
sql="Select * from tmhol "
sql=sql & "order by dt_hol"
rs.open sql, conn
if len(sParam) > 0 then
do while not rs.eof
bflag=true
Set rs1=server.CreateObject("ADODB.Recordset")
sql="Select * from tmhol1 "
sql = sql & " where hol_id = '" & sParam & "'"
sql = sql & " order by dt_hol"
rs1.open sql, conn
do while not rs1.eof
if fdate2(rs("DT_HOL")) = fdate2(rs1("DT_HOL")) then
bflag= false
exit do
end if
rs1.movenext
loop
if bflag = true then
response.write "<option value='" & rs("DT_HOL") & "," & rs("PART") & "'>" & rs("DT_HOL") & " - " & rs("PART") & "</option>"
end if
rs.movenext
loop
else
do while not rs.eof
if year(rs("DT_HOL")) = year(date) then
response.write "<option value='" & rs("DT_HOL") & "," & rs("PART") & "'>" & rs("DT_HOL") & " - " & rs("PART") & "</option>"
end if
rs.movenext
loop
pCloseTables(rs)
end if
end function
Set rstTMHOL1 = server.CreateObject("ADODB.RecordSet")
sSQL = "select * from TMHOL1 where HOL_ID ='" & sID & "'"
rstTMHOL1.Open sSQL, conn, 3, 3
if not rstTMHOL1.eof then
sName = rstTMHOL1("Name")
end if
%>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<!-- #include file="include/header.asp" -->
<!-- Left side column. contains the logo and sidebar -->
<!-- #include file="include/sidebar_tm.asp" -->
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>Holiday Calendar Details</h1>
</section>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-md-12">
<div class="box">
<!-- /.box-header -->
<div class="box-body ">
<form name="form1" class="form-horizontal" action="tmholcal_det.asp" method="POST">
<input type="hidden" name="Page" value='<%=iPage%>' />
<div class="form-group">
<label class="col-sm-3 control-label">Holiday Calendar Code : </label>
<div class="col-sm-7">
<% if sHOL_ID <> "" then %>
<span class="mod-form-control"><% response.write sHOL_ID%> </span>
<input type="hidden" id="txtID" name="txtID" value="<%=sHOL_ID%>" />
<%else%>
<input class="form-control" id="txtID" name="txtID" value="<%=sID%>" maxlength="30" style="text-transform: uppercase" input-check />
<% end if %>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Name : </label>
<div class="col-sm-7">
<input class="form-control" id="txtName" name="txtName" value="<%=server.Htmlencode(sName)%>" maxlength="30">
</div>
</div>
<!--<div class="form-group">
<label class="col-sm-3 control-label">Year : </label>
<div class="col-sm-2">
<%if sSHFPAT_ID <> "" then%>
<span class="mod-form-control"><% response.write sYear%> </span>
<input type="hidden" id="selYear" value="<%=sYear%>" />
<%else%>
<select name="selYear" id="selYear" class="form-control">
<%For i = 1 to 34
selyear = Cint(2016) + Cint(i)
%>
<option value="<%=selyear%>" <%if sYear = selyear then%>Selected<%end if%>><%=selyear%></option>
<%Next%>
</select>
<% end if %>
</div>
</div>-->
<div>
<table id="example1">
<tbody>
<tr>
<td width="5%"></td>
<td width="20%" style="padding: 7px"><b>Available Dates :</b>
<select multiple size="15" style="width: 405px;" name="FromLB" id="FromLB" ondblclick="move(this.form.FromLB,this.form.ToLB)">
<%
ShowAvailDates(sHOL_ID)
%>
</select>
</td>
<td width="3%" style="padding: 9px" align="center">
<input type="button" class="btn btn-primary" style="width: 50px" onclick="move(this.form.FromLB, this.form.ToLB)" value=" > ">
<br>
<br>
<input type="button" class="btn btn-primary" style="width: 50px" onclick="move(this.form.ToLB, this.form.FromLB)" value=" < ">
</td>
<td width="30%" style="padding: 11px"><b>Selected : </b>
<select multiple size="15" style="width: 405px;" name="ToLB" id="ToLB" ondblclick="move(this.form.ToLB,this.form.FromLB)">
<% Set rstTMHOL1 = server.CreateObject("ADODB.RecordSet")
sSQL = "select * from TMHOL1 where HOL_ID ='" & sID & "'"
rstTMHOL1.Open sSQL, conn, 3, 3
do while not rstTMHOL1.eof
response.write "<option value='" & rstTMHOL1("DT_HOL") & "," & rstTMHOL1("PART") & "' selected='selected'>" & rstTMHOL1("DT_HOL") & " - " & rstTMHOL1("PART") & "</option>"
rstTMHOL1.movenext
loop
%>
</select>
</td>
</tr>
</tbody>
</table>
</div>
<div class="box-footer">
<%if sHOL_ID <> "" then %>
<a href="#" data-toggle="modal" data-target="#modal-delholcal" data-hol_id="<%=server.htmlencode(sHOL_ID)%>"
class="btn btn-danger pull-left" style="width: 90px">Delete</a>
<button type="submit" name="sub" value="up" class="btn btn-info pull-right" style="width: 90px">Update</button>
<%else%>
<button type="submit" name="sub" value="save" class="btn btn-default pull-right"
style="width: 90px">
Save</button>
<%end if%>
</div>
</form>
</div>
<!-- /.box-body -->
</div>
</div>
<!-- /.col -->
</div>
<!-- /.row -->
<div class="modal fade bd-example-modal-lg" id="modal-delholcal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="exampleModalLabel"></h4>
</div>
<div class="modal-body">
<div id="del-content">
<!--- Content ---->
</div>
</div>
</div>
</div>
</div>
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
<!-- #include file="include/footer.asp" -->
</div>
<!-- ./wrapper -->
<!-- input-check -->
<script src="plugins/Custom/input-check.js"></script>
<script>
$('#modal-delholcal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget) // Button that triggered the modal
var hol_id = button.data('hol_id')
var modal = $(this)
modal.find('.modal-body input').val(hol_id)
showDelmodal(hol_id)
})
function showDelmodal(str){
var xhttp;
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
document.getElementById("del-content").innerHTML = xhttp.responseText;
}
};
xhttp.open("GET", "tmholcal_del.asp?txtstring="+str, true);
xhttp.send();
}
</script>
<script>
function move(tbFrom, tbTo) {
var arrFrom = new Array(); var arrTo = new Array();
var arrLU = new Array();
var i;
for (i = 0; i < tbTo.options.length; i++) {
arrLU[tbTo.options[i].text] = tbTo.options[i].value;
arrTo[i] = tbTo.options[i].text;
}
var fLength = 0;
var tLength = arrTo.length;
for(i = 0; i < tbFrom.options.length; i++) {
arrLU[tbFrom.options[i].text] = tbFrom.options[i].value;
if (tbFrom.options[i].selected && tbFrom.options[i].value != "") {
arrTo[tLength] = tbFrom.options[i].text;
tLength++;
} else {
arrFrom[fLength] = tbFrom.options[i].text;
fLength++;
}
}
tbFrom.length = 0;
tbTo.length = 0;
var ii;
for(ii = 0; ii < arrFrom.length; ii++) {
var no = new Option();
no.value = arrLU[arrFrom[ii]];
no.text = arrFrom[ii];
no.selected = true;
tbFrom[ii] = no;
}
for(ii = 0; ii < arrTo.length; ii++) {
var no = new Option();
no.value = arrLU[arrTo[ii]];
no.text = arrTo[ii];
no.selected = true; // I enable it because when
tbTo[ii] = no;
}
}
</script>
</body>
Basically I got the flow wrong. I should have remove all the no.selected=true in the javascript code and add the following Jquery
$(document).ready(function () {
$('#btnUp').click(function () {
$('#ToLB').each(function () {
$('#ToLB option').attr("selected", "selected");
});
});
});
$(document).ready(function () {
$('#btnSave').click(function () {
$('#ToLB').each(function () {
$('#ToLB option').attr("selected", "selected");
});
});
});
Basically the Jquery will select all the options when btnSave or btnUpdate is clicked.
Hence, the server will manage to pick up the values of the option tags.
I have to call things from code behind.I am able to call Html from code behind like this :
Which looks Like this
<h1>cubus outperform EV Analytics</h1>
<div style="margin:0px; position:absolute; top:12px; left:0px; bottom:0px; right:0px;" id="EVObject_xml">
<object id="EVObject" name="EVObject" lang="en-US"
width="100%" height="100%" CodeBase="http://kl12ACUC/EVServer/Client/Ctrl.cab#version=11,0,0,0"
ClassId="clsid:80AC1200-0BBE-499A-A9E9-5F334DBC8E89">
<param Name="Server" Value="kl12ACUC" />
<param Name="EnableTabBar" Value="True" />
<param Name="Theme" Value="Ribbon" />
</object>
</div>
<div id="ribbon" />
<div id="backstage-container" />
And Now It Looks Like this in Code Behind
string strHTMLGrid = "";
strHTMLGrid = strHTMLGrid + "<h1>" + sHeading + "</h1>";
strHTMLGrid = strHTMLGrid + "<div id='EVObject_xml' style='margin: 0px; position: absolute; top: 12px; left: 0px; bottom: 0px; right: 0px; '>";
strHTMLGrid = strHTMLGrid + "<object name='EVObject' width='100%' height='100%' id='EVObject' codebase='" + sUrlHtml + "' lang='en-US' classid='clsid:80AC1200-0BBE-499A-A9E9-5F334DBC8E89'>";
strHTMLGrid = strHTMLGrid + "<param name='Server' value='" + sServername1 + "'>";
strHTMLGrid = strHTMLGrid + "<param name='Server' value='" + sTheme1 + "'>";
strHTMLGrid = strHTMLGrid + "<param name='Server' value='" + sHeading + "'>";
strHTMLGrid = strHTMLGrid + "</object>";
strHTMLGrid = strHTMLGrid + "</div>";
strHTMLGrid = strHTMLGrid + "<div id='ribbon'>";
strHTMLGrid = strHTMLGrid + "<div id='backstage - container'> </div>";
strHTMLGrid = strHTMLGrid + "</div>";
Now I need to call the JavaScript Function on the load of the body of this html document.The code I do have with me looks like this
function OpenCube()
{
EVObject.Enable(UIAuthorisationType.UIAuthorisationToolbar, true);
EVObject.Enable(UIAuthorisationType.UIAuthorisationTabBar, true);
EVObject.TabBarPosition = TabBarPositionType.TabBarPositionBottom;
EVObject.Allow(ActionAuthorisationType.UIAuthorisationToolbarText, false);
EVObject.ToolBar.LargeButtons = false;
EVObject.Enable(UIAuthorisationType.UIAuthorisationLocalViews, false);
EVObject.Allow(ActionAuthorisationType.ActionAuthorisationDataEntry, false);
EVObject.Allow(ActionAuthorisationType.ActionAuthorisationSaveView, true);
EVObject.Allow(ActionAuthorisationType.ActionAuthorisationExport, true);
EVObject.Allow(ActionAuthorisationType.ActionAuthorisationExportToExcel, true);
EVObject.ViewLocations = "General=/";
EVObject.object.attachEvent("NeedDataSourceCredentials", DataSourceCredentials);
EVObject.object.attachEvent("NeedServerCredentials", ServerCredentials);
EVObject.Views.Open("/Outdb/mis");
LeaveBackstage();
ExpandRibbons(false);
ShowBackstage(false);
}
1)Problem No.1 ====Now How do I call the javascript Function in C#.
2)Problem No.2===== How to call the Javascript function the load of body in which I have written the html document.
You should use RegisterStartupScript
private void Page_Load(object sender, System.EventArgs e)
{
string jScriptValidator;
jScriptValidator="<script> function ReqFieldValidator()" +
" { if (document.forms[0].txtField.value == '') \n";
jScriptValidator+="{ alert('TextBox cannot be empty') \n ";
jScriptValidator+="return false; \n";
jScriptValidator+="} \n";
jScriptValidator+=" return true \n";
jScriptValidator+=" } </script>";
Page.RegisterStartupScript("regJSval",jScriptValidator);
btnSubmit.Attributes.Add("onclick","return ReqFieldValidator()");
}
For more you can refer this page :
http://www.codeproject.com/Articles/11098/Use-Call-RegisterStartUpScript-RegisterClientScrip
As I heard from an interviewer Before visual studio 2013,people had this problem,they wanted to call javascript in code behind file.So below is one of the way using runat="server" tag.
<script runat="server">
//your java script code
</script>
Above code will be called after client side i.e it will be executed at server side
I have a bit of JQuery that I am trying to use to detect if the value that is in a data list select box is actually in the list, here is what i have.
<div class='form-row'>
<div class='col-xs-12 form-group required' style="margin-top: -2px; margin-bottom: 0px;">
<h2>
<label class='control-label' style="font-size: 20px;">
Product code
</label>
</h2>
<input required id="ItemSelect" list=jobs style='font-size:21px;height: 40px;' class='form-control' name="Code">
<datalist id="jobs">
<?php
foreach ($this->Products as $a) {
$inputValue = " " . htmlentities($a["Code"] . " | " . $a["Name"]) . " ";
echo '<option>' . $inputValue;
}
?>
</datalist>
</div>
$('#submit').on('click', function (e) {
var datalistval = $('#ItemSelect').val();
console.log(datalistval);
console.log($("#ItemSelect option[value='" + datalistval + "']").length)
if ($("#ItemSelect option[value='" + datalistval + "']").val() === undefined) {
console.log("not there");
} else {
console.log(" there");
}
});
currently with this if i enter a value that is not in the list it comes back as no there, but it also comes back as not there if i do select one out of the list.
Here out the outputs of the console.logs
console.log(datalistval); // X01A172 | Sub Assembly 2
console.log($("#ItemSelect option[value='" + datalistval + "']").length) // 0
not there
I've seen several of posts regarding this subject, but I have not managed to solve my own problem despite of having tried different methods.
I am programming in a .hta file, where I have all my notes titles listed above each other. Whenever you click a note title the description should appear (toggle/expand) under the title. All the notes should start hidden.
sub searchdata
SQL_query = "SELECT * FROM dvd WHERE Title LIKE '%"& txtsrch.value &"%' OR Notes LIKE '%"& txtsrch.value &"%' ORDER BY Title"
Set rsData = conn.Execute(SQL_query)
strHTML2 = strHTML2 & ""
Do Until rsData.EOF = True
strHTML2 = strHTML2 & "<table width='97%' border='0' id='bodytext' style='border-bottom: solid #000000 1px;'><tr><span class'togglelink'><td width='70%' style='cursor: pointer'><b>" & rsData("Title") & "</b></td></span><td align='right' style='color: #000'>" & rsData("Cat") & " <a href='#' onclick='editUser("& rsData("ID") &")' language='vbscript'><img src='images/arrow-blue.png' border='0' title='Rediger notatet' /></a> <a href='#' onclick='deleteUser("& rsData("ID") &")' language='vbscript'><img src='images/slet.png' border='0' title='Slet notatet' /></a></td><tr><span class='toggle' style='display: block'><td colspan='2'>" & rsData("Notes") & "</td></span></tr></table>"
rsData.moveNext ' go to next record
Loop
strHTML2 = strHTML2 & ""
searchIT.innerHTML = strHTML2
end sub
I am using this JS script to run it:
<script type="text/javascript">
$(document).ready(function () {
$('.toggle').hide();
$('span.togglelink').on('click', function (e) {
e.preventDefault();
var elem = $(this).next('.toggle')
$('.toggle').not(elem).hide('fast');
elem.toggle('fast');
});
});
</script>
I can easily get the script to work when testing with just plain text.
JSFiddle
Side question: Is programming in a HTA really so different from HTML? I'm running in to a lot of problems trying to convert my whole site (MySQL, PHP, HTML) to working in HTA.
Thanks in advance!
Update: Listed my whole .hta script:
<html>
<HTA:APPLICATION ID="oHTA"
APPLICATIONNAME="myApp"
BORDER="thick"
CAPTION="yes"
ICON=./images/Icon.ico
MAXIMIZEBUTTON="yes"
MINIMIZEBUTTON="yes"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="no"
SYSMENU="yes"
RESIZE="yes"
VERSION=7.2
WINDOWSTATE="normal"
contextMenu=no
>
<head>
<style>
#vis1{
display:none;
}
</style>
<script type="text/javascript"> // Width and height in pixel to the window
window.resizeTo(683,725);
</script>
<script type="text/javascript">
var enablepersist="on" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="Yes" //Collapse previously open content when opening present? (yes/no)
if (document.getElementById){
document.write('<style type="text/css">')
document.write('.switchcontent{display:none;}')
document.write('</style>')
}
function getElementbyClass(classname){
ccollect=new Array()
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags[i].className==classname)
ccollect[inc++]=alltags[i]
}
}
function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}
function expandcontent(cid){
if (typeof ccollect!="undefined"){
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
}
}
function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
}
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}
function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}
document.cookie=window.location.pathname+"="+selectedItem
}
function do_onload(){
uniqueidn=window.location.pathname+"firsttimeload"
getElementbyClass("switchcontent")
if (enablepersist=="on" && typeof ccollect!="undefined"){
document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0"
firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 //check if this is 1st page load
if (!firsttimeload)
revivecontent()
}
}
if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload
if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate
</script>
<title>Søgning</title>
<link href="stylesheet/stylesheet.css" rel="stylesheet" type="text/css" />
<link rel="SHORTCUT ICON" href="images/icon.ico"/>
<script type="text/javascript" charset="utf-8" src="jquery/jquery-1.7.min.js"></script>
<script language="vbscript">
Dim conn 'GLOBAL doing this here so that all functions can use it
sub dotheconnection
Set conn = CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source =./Database/data.mdb; User Id=; Password="
If conn.errors.count <> 0 Then
else
' if connected OK call sub getdata
getdata
end if
end sub
sub getdata
SQL_query = "SELECT * FROM dvd ORDER BY Title"
Set rsData = conn.Execute(SQL_query)
strHTML = strHTML & ""
Do Until rsData.EOF = True
strHTML = strHTML & "<table width='97%' border='0' id='bodytext' style='border-bottom: solid #000000 1px;'><tr><td width='70%' style='cursor: pointer'><span id='vis'><b>" & rsData("Title") & "</b></span></td><td align='right' style='color: #000'>" & rsData("Cat") & " <a href='#' onclick='editUser("& rsData("ID") &")' language='vbscript'><img src='images/arrow-blue.png' border='0' title='Rediger notatet' /></a> <a href='#' onclick='deleteUser("& rsData("ID") &")' language='vbscript'><img src='images/slet.png' border='0' title='Slet notatet' /></a></td><tr><td colspan='2'><span id='vis1'>" & rsData("Notes") & "</span></td></tr></table>"
rsData.moveNext ' go to next record
Loop
strHTML = strHTML & ""
SQL_query = "SELECT Count(*) AS intTotal FROM dvd"
Set rsData = conn.Execute(SQL_query)
strHTML1 = strHTML1 & ""
strHTML1 = strHTML1 & "" & rsData("intTotal") & " "
Count.innerHTML = strHTML1
end sub
sub searchdata
SQL_query = "SELECT * FROM dvd WHERE Title LIKE '%"& txtsrch.value &"%' OR Notes LIKE '%"& txtsrch.value &"%' ORDER BY Title"
Set rsData = conn.Execute(SQL_query)
strHTML2 = strHTML2 & ""
Do Until rsData.EOF = True
strHTML2 = strHTML2 & "<table width='97%' border='0' id='bodytext' style='border-bottom: solid #000000 1px;'><tr><span class'togglelink'><td width='70%' style='cursor: pointer'><b>" & rsData("Title") & "</b></td></span><td align='right' style='color: #000'>" & rsData("Cat") & " <a href='#' onclick='editUser("& rsData("ID") &")' language='vbscript'><img src='images/arrow-blue.png' border='0' title='Rediger notatet' /></a> <a href='#' onclick='deleteUser("& rsData("ID") &")' language='vbscript'><img src='images/slet.png' border='0' title='Slet notatet' /></a></td><tr><span class='toggle' style='display: block'><td colspan='2'>" & rsData("Notes") & "</td></span></tr></table>"
rsData.moveNext ' go to next record
Loop
strHTML2 = strHTML2 & ""
searchIT.innerHTML = strHTML2
end sub
sub deleteUser(id)
If MsgBox("Vil du slettet dette notat?", vbYesNo) =vbYes Then
SQL_query = "DELETE * FROM dvd WHERE ID = " & id
conn.Execute(SQL_query)
getdata
reloadpage()
Else
MsgBox("Notatet er ikke blevet slettet.")
End IF
end sub
sub addUser
SQL_query = "INSERT INTO dvd (Title,Length,Notes,Cat) VALUES ('"& txtTitle.value &"','"& txtLength.value &"','"& txtNotes.value &"','"& txtCat.value &"')"
conn.Execute(SQL_query)
reloadpage()
expandcontent("sc2")
getdata
end sub
sub editUser(id)
SQL_query = "SELECT * FROM dvd WHERE ID=" & id
Set rsData=conn.Execute(SQL_query)
txtTitle.value = rsData("Title")
txtLength.value = rsData("Length")
txtNotes.value = rsData("Notes")
txtCat.value = rsData("Cat")
txtID.value = rsData("ID")
btnUpdate.disabled = false // Show
btnOpret.disabled = true // Hide
expandcontent("sc2")
getdata
end sub
sub updateUser
SQL_query = "UPDATE dvd SET Title='"& txtTitle.value &"', Length='"& txtLength.value &"' , Notes='"& txtNotes.value &"', Cat='"& txtCat.value &"' WHERE ID= " & txtID.value
conn.Execute(SQL_query)
getdata
reloadpage()
expandcontent("sc2")
end sub
</script>
<script type="text/javascript" charset="utf-8" src="jquery/jquery-1.7.min.js"></script>
<SCRIPT TYPE="text/javascript">
function init()
{
dotheconnection();
searchdata();
getdata();
}
</SCRIPT>
<script>
function addNotat() {
btnOpret.disabled = false; // Show
btnUpdate.disabled = true; // Hide
expandcontent("sc2");
}
</script>
<script>
function reloadpage() {
location.reload();
}
</script>
<script type="text/javascript">
$(document).ready(function () {
$('.toggle').hide();
$('div.togglelink').on('click', function (e) {
e.preventDefault();
var elem = $(this).next('.toggle')
$('.toggle').not(elem).hide('fast');
elem.toggle('fast');
});
});
</script>
</head>
<body onLoad="init()" language="vbscript">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="40" width="20%" id="top_bar">
<input language="vbscript" onload="searchdata" onkeyup="searchdata" name="txtsrch" id="filter_input" width="15%" tabindex="0" autofocus="autofocus" size="35" type="search" style="background: url(images/search_bg.png) #FFF no-repeat left; padding-left: 20px; margin-left: 10px" placeholder="Søgning"> </td>
<td id="top_bar"></div><span id="Count"></span> notater </td>
<td width="22%" id="top_bar" align="right"><input type="button" style="margin-right: 10px" onClick="history.go(0)" value="Opdater"><a onClick="addNotat()" style="cursor: hand">Opret</a> </span></td>
<td width="20%" id="top_bar" align="right"><img src="images/footer-logo.png" style="margin-right: 10px" border="0" title="Gå til forsiden" /></td>
</tr>
</table>
<br>
<div id="sc2" class="switchcontent" style="margin-left: 10px">
<b>Title:<br></b><input type="text" name="txtTitle" size="43"><br>
<b>Kategori:</b><br>
<select size="1" name="txtCat">
<option value="">Vælg kategori</option>
<option value="Thriller">Thriller</option>
<option value="Westerns">Westerns</option>
</select><br>
<b>Length</b><br><input type="text" name="txtLength" size="8"><br>
<b>Notat:</b><br><textarea rows="6" name="txtNotes" cols="55"></textarea><br>
<p align="left"><b>
<input type="button" name="btnOpret" value="Opret" onclick="addUser" language="vbscript" disabled>
<input type="button" name="btnUpdate" value="Gem" onclick="updateUser" language="vbscript" disabled>
<input type="hidden" name="txtID">
</b></p>
</div>
</div>
<div id="searchIT" style="margin-left: 10px"></div>
</body>
</script>
</html>
The div.togglelink's will be attached after the document has been loaded, your on-handler will only have an effect to elements that are present when the document loads.
Attach the handler to the body instead:
$('body').on('click','span.togglelink',function(){/*your callback*/});
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Deobfuscating Javascript
Can someone help me to deobfuscating this?
I tried many way but there is no hope.
<script type="text/javascript">
//<![CDATA[
<!--
var x = "function f(x){var i,o=\"\",l=x.length;for(i=0;i<l;i+=2) {if(i+1<l)o+=" + "x.charAt(i+1);try{o+=x.charAt(i);}catch(e){}}return o;}f(\"ufcnitnof x({)av" + " r,i=o\\\"\\\"o,=l.xelgnhtl,o=;lhwli(e.xhcraoCedtAl(1/)3=!11)0t{yrx{=+;x+ll" + "=};acct(h)e}{f}roi(l=1-i;=>;0-i)-o{=+.xhcratAi(;)r}teru n.oussbrt0(o,)l};(f" + ")\\\"96\\\\,5\\\"00\\\\\\\\5. /3>02\\\\\\\\qL)hn>\\\"\\\\\\\\\\\\BLc0bn37\\" + "\\0J\\\\21{81d02\\\\\\\\\\\\\\\\\\\\\\\\!jl:\\\\\\\\\\\\\\\\14\\\\0b\\\\| -" + "r^<36\\\\0>\\\\&.\\\"\\\\\\\\\\\\^ BPZ|d<\\\\n1\\\\02\\\\\\\\\\\"\\\\\\\\\\" + "\\)0\\\"\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\"\\\\\\\\\\\\WjDCSW\\\\\\\\\\\\\\\\#" + "bskan10\\\\06\\\\03\\\\\\\\R<kr4m03\\\\\\\\mKZ,e?16\\\\0G\\\\.j^$7t02\\\\\\" + "\\|Su{\\\\ \\\\\\\\C\\\\s[ho\\\"\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\"\\\\\\\\\\\\" + "05\\\\0{\\\\i` lPDgqcr1r02\\\\\\\\{]+jxv33\\\\0J\\\\5>r~^6nF&>g820\\\\0W\\\\" + "jzrgE nF7>\\\"\\\\\\\\\\\\n:\\\\\\\\yVtgn/27\\\\0Y\\\\ol\\\\k\\\\\\\";\\\\0" + "6\\\\0N\\\\<*8&6t02\\\\\\\\wYnke/20\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\XS01\\\\02\\" + "\\00\\\\\\\\10\\\\00\\\\03\\\\\\\\02\\\\00\\\\03\\\\\\\\36\\\\0F\\\\23\\\\0" + "0\\\\01\\\\\\\\00\\\\0t\\\\\\\\\\\\26\\\\01\\\\00\\\\\\\\16\\\\04\\\\00\\\\" + "\\\\\\\"\\\\f(;} ornture;}))++(y)^(iAtdeCoarchx.e(odrChamCro.fngriSt+=;o27=" + "1y%2;*=)yy)6+(9i>f({i+)i+l;i<0;i=r(foh;gten.l=x,l\\\"\\\\\\\"\\\\o=i,r va){" + ",y(x fontincfu)\\\"\")";
while (x = eval(x));
//-->
//]]>
it is encoded in 3 steps, if you replace while (x = eval(x)); by :
var res = eval(x);
var res2 = eval(res);
var res3 = eval(res2);
res3 will have the following value :
document.writeln("<form action=\"http://ongkir.info/mobile/find_cost\" method=\"post\" accept-charset=\"utf-8\" target=\"_blank\">\r\n<table border=\"0\" style=\"font: Normal 14px Arial;\"> <tbody>\r\n<tr>\r\n <th align=\"left\" valign=\"middle\"><br />\r\nCEK TARIFF KURIR</th>\r\n <td><br />\r\n<img src=\"http://jne.co.id/images/favicon.ico\" width=\"50\" height=\"30\"/></td>\r\n </tr>\r\n\t\t\r\n\t\t<input type=\"hidden\" name=\"courier_type\" value=\"jne\"/>\r\n\r\n<tr>\r\n <td><br />\r\nFROM</td>\r\n <td><br />\r\n\t\t <input name=\"daerah_asal\" value=\"\" size=\"20\" style=\"border: 1px solid #3b6e22; color: #666666;\" type=\"text\" /></td>\r\n </tr>\r\n<tr>\r\n <td><br />\r\nTO</td>\r\n <td><br />\r\n<input name=\"daerah_tuju\" value=\"\" size=\"20\" style=\"border: 1px solid #3b6e22; color: #666666;\" type=\"text\" /></td>\r\n </tr>\r\n<tr>\r\n <td><br />\r\nWEIGHT (gram)</td>\r\n <td><br />\r\n<input name=\"weight\" value=\"1000\" size=\"20\" style=\"border: 1px solid #3b6e22; color: #666666;\" type=\"text\" /></td>\r\n </tr>\r\n<tr>\r\n <td><br />\r\n<span style=\"font-size: x-small;\">Copyright WAHYUPUTRA</span></td>\r\n <td><br />\r\n<input style=\"background: #6AA450; border: 1px solid #3b6e22; color: white; display: inline-block; font-size: 12px; height: 24px; line-height: 24px; margin-right: 10px; padding: 0px 6px; text-decoration: none;\" name=\"submit\" type=\"submit\" value=\"SUBMIT\" /></td>\r\n </tr>\r\n</tbody></table>\r\n</form>");