We have a large system written in VB6, one part of the system uses a WebControl to present the user with a BING map. This is using the V7 of the BING webcontrol. Microsoft have deprecated the V7 control so I'm trying to migrate to V8 but I'm having some problems.
The Bing WebControl V8 requires IE11 (although it does work on IE10), but the WebControl by default only uses the IE7 rendering engine. You can tell it to use a later engine (if available) by writing a registry key:
HKCU\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\<exe name> REG_DWORD 11000
That works fine when the program is compiled, but doesn't work when running from the VB6 IDE, so debugging is a PITA. I've set both the compiled EXE name and also VB6.EXE in the registry, but it doesn't work within VB6.
Any ideas as to how I get the WebControl to use IE10/11 rendering when running within the IDE? This is on Windows 7 btw.
EDIT
Here is my code:
Add a WebBrowser control to a form, call it msIE.
Option Explicit
Private mstrHTTP As String
Public mstrAPI_Key As String
Private Sub Form_Load()
Me.Caption = "Name : '" & App.EXEName & "'"
mstrHTTP = ""
mstrAPI_Key = "Your BING API key here"
msIE.Navigate ("about:blank")
Call BuildFunction(mstrHTTP, "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">")
Call BuildFunction(mstrHTTP, "<html>")
Call BuildFunction(mstrHTTP, " <head>")
Call BuildFunction(mstrHTTP, " <meta http-equiv='X-UA-Compatible' content='IE=Edge' />")
Call BuildFunction(mstrHTTP, " <title>Load map with navigation bar module</title>")
Call BuildFunction(mstrHTTP, " <meta charset='utf-8' />")
Call BuildFunction(mstrHTTP, " ")
Call BuildFunction(mstrHTTP, " <!-- Reference to the Bing Maps SDK -->")
Call BuildFunction(mstrHTTP, " <script type='text/javascript'")
Call BuildFunction(mstrHTTP, " src='http://www.bing.com/api/maps/mapcontrol?callback=GetMap'")
Call BuildFunction(mstrHTTP, " async defer></script>")
Call BuildFunction(mstrHTTP, " ")
Call BuildFunction(mstrHTTP, " <script type='text/javascript'>")
Call BuildFunction(mstrHTTP, " function GetMap()")
Call BuildFunction(mstrHTTP, " {")
Call BuildFunction(mstrHTTP, " var map = new Microsoft.Maps.Map('#myMap', {")
Call BuildFunction(mstrHTTP, " credentials: '" & mstrAPI_Key & "'")
Call BuildFunction(mstrHTTP, " ,enableInertia: false")
Call BuildFunction(mstrHTTP, " ,showMapTypeSelector: false")
Call BuildFunction(mstrHTTP, " ,showZoomButtons: false")
Call BuildFunction(mstrHTTP, " ,showLocateMeButton: false")
Call BuildFunction(mstrHTTP, " });")
Call BuildFunction(mstrHTTP, " // Add post map load code here")
Call BuildFunction(mstrHTTP, " }")
Call BuildFunction(mstrHTTP, " </script>")
Call BuildFunction(mstrHTTP, " </head>")
Call BuildFunction(mstrHTTP, " <body style='margin:0;'>")
Call BuildFunction(mstrHTTP, " <div id='myMap' style='width:100%;height:100%;'></div>")
Call BuildFunction(mstrHTTP, " </body>")
Call BuildFunction(mstrHTTP, "</html>")
msIE.Document.write (mstrHTTP)
End Sub
Private Sub BuildFunction(ByRef theString As String, ByRef extraString As String)
theString = theString & extraString & vbCrLf
End Sub
Private Sub Form_Resize()
msIE.Top = 0
msIE.Left = 0
msIE.Width = Me.ScaleWidth
msIE.Height = Me.ScaleHeight
End Sub
Add the following to the header of your HTML page:
<meta http-equiv="x-ua-compatible" content="IE=Edge"/>
This will tell the Web Control to use the latest version of IE installed on the machine.
Related
A friend of mine asked me a favor, help him to install CK Editor into SnitzForum (yeah old I know). Since I am not into asp lang. I have a problem since after putting into the head the CDN code I have to put below the tag this code:
<script> CKEDITOR.replace( 'editor1' ); </script>
So this is the part where the textarea is into the file post.asp:
<%
end if
end if
Response.Write " </font></td>" & vbNewLine & _
" </tr>" & vbNewLine & _
" </table>" & vbNewLine & _
" </font></td>" & vbNewLine & _
" <td bgColor=""" & strPopUpTableColor & """><textarea cols=""" & intCols & """ name=""editor1"" rows=""" & intRows & """ wrap=""VIRTUAL"" onselect=""storeCaret(this);"" onclick=""storeCaret(this);"" onkeyup=""storeCaret(this);"" onchange=""storeCaret(this);"">" & Trim(CleanCode(TxtMsg)) & "</textarea><br /></td>" & vbNewLine & _
" </tr>" & vbNewLine
end if
select case strRqMethod
case "Reply", "ReplyQuote", "TopicQuote"
Response.Write " <script language=""JavaScript"" type=""text/javascript"">document.PostTopic.Message.focus();</script>" & vbNewLine
end select
How can I add that script? Thanks :)
Edited Code:
<!--#INCLUDE FILE="inc_smilies.asp" -->
<%
end if
end if
Response.Write " </font></td>" & vbNewLine & _
" </tr>" & vbNewLine & _
" </table>" & vbNewLine & _
" </font></td>" & vbNewLine & _
" <td bgColor=""" & strPopUpTableColor & """><textarea cols=""" & intCols & """ name=""Message"" rows=""" & intRows & """ wrap=""VIRTUAL"" onselect=""storeCaret(this);"" onclick=""storeCaret(this);"" onkeyup=""storeCaret(this);"" onchange=""storeCaret(this);"">" & Trim(CleanCode(TxtMsg)) & "</textarea><br /></td>" & vbNewLine & _
" </tr>" & vbNewLine
%>
<script>
tinymce.init({
selector: 'textarea',
toolbar_mode: 'floating',
});
</script>
<%
end if
select case strRqMethod
case "Reply", "ReplyQuote", "TopicQuote"
Response.Write " <script language=""JavaScript"" type=""text/javascript"">document.PostTopic.Message.focus();</script>" & vbNewLine
end select
Ok, so an working example with a text box could (would) be this:
<script src="https://cdn.ckeditor.com/4.16.2/standard/ckeditor.js"></script>
<div style="width:50%">
<asp:TextBox ID="TextBox1" runat="server" Height="304px" Width="617px"
TextMode="MultiLine"
ClientIDMode="Static"
></asp:TextBox>
</div>
<script>
CKEDITOR.replace('TextBox1');
</script>
And we now get this:
So, as noted, it probably better to hide/show the one div above, then trying to inject the above markup into the page. And the REASON why is that then in code behind, you want to be able to get the textbox by using
TextBox1.text
So, by placing a plane jane text box (TextBox1) on the form, then code behind can use that text box. If you inject the markup, then code behind will have a much more difficult time using that markup and using TextBox1.Text to get the results of the markup in that text box.
So I don't see the need to use "code" to inject the above. As I noted, perhaps you need to hide/show this?
Then add a "ID" to the div like this:
<div id="mycooleditor" runat="server" style="width:35%;display:none">
<asp:TextBox ID="TextBox1" runat="server" Height="304px" Width="617px"
TextMode="MultiLine"
ClientIDMode="Static"
></asp:TextBox>
</div>
Now, in code behind, to display the editor, we can go:
mycooleditor.Style.Add("display", "normal")
So, unless you make a REALLY good case as to why we using code to inject the html into the web page as opposed just dropping in the markup as per above without any code (and saving world poverty's at the same time), then I see no reason to spend the time + effort writing code that does the same thing?
You can write code to inject, but I see no reason why when you can just drop in the markup anyway???
Overworked. Put the tinymce files in their own folder (titled "tinyMCE") below the forum root. In the file "inc_header.asp", look for this code (appx lines 240-242):
'## START - REMOVAL, MODIFICATION OR CIRCUMVENTING THIS CODE WILL VIOLATE THE SNITZ FORUMS 2000 LICENSE AGREEMENT
Response.Write "<meta name=""copyright"" content=""This Forum code is Copyright (C) 2000-09 Michael Anderson, Pierre Gorissen, Huw Reddick and Richard Kinser, Non-Forum Related code is Copyright (C) " & strCopyright & """>" & vbNewline
'## END - REMOVAL, MODIFICATION OR CIRCUMVENTING THIS CODE WILL VIOLATE THE SNITZ FORUMS 2000 LICENSE AGREEMENT
Below that bit, insert this:
If strScriptName = "post.asp" Then
Response.Write " <script src=""./tinyMCE/tinymce.js""></script>" & vbNewLine & _
" <script language=""Javascript"">tinymce.init ({" & vbNewLine & _
" selector:'textarea'," & vbNewLine & _
" theme:'modern'," & vbNewLine & _
" browser_spellcheck:'true'," & vbNewLine & _
" plugins:['advlist anchor autolink charmap code contextmenu directionality emoticons fullscreen hr insertdatetime image link lists media nonbreaking paste print preview pagebreak save searchreplace table template textcolor visualblocks visualchars wordcount']," & vbNewLine & _
" content_css:'css/combined-min.css'," & vbNewLine & _
" toolbar:'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | preview media fullpage | forecolor backcolor emoticons'," & vbNewLine & _
" });</script>" & vbNewLine
End If
That will take over all instances of the text area in "post.asp". If you want to use it throughout the forum for text areas, remove the If/End If lines.
I am populating a treelist in the run-time. I want to add a checkbox to every leaf of the treelist. I am using the function below to populate the treeview and it works fine. but I am not able to access the checkbox
here is my code
Private Function GetChilds(ParentID As Integer) As String
Dim ChildsStr As String = ""
SQL = "Select Category_Name,Category_ID from Categories where Category_IsDeleted=0 and Category_ParentID=" & ParentID & " order by Category_Order"
Dim drx As SqlDataReader
drx = PF.ExecuteReader(SQL)
If drx.HasRows Then
ChildsStr += "<ul style='display: block'>" & vbNewLine
Do While drx.Read
Dim Ishavechd As Boolean = IsHaveChild(drx("Category_ID"))
If Ishavechd Then
ChildsStr += "<li class=""file-tree-folder open"">" & vbNewLine
Else
ChildsStr += "<li>" & vbNewLine
End If
ChildsStr += drx("Category_Name") & " "
If Not Ishavechd Then ChildsStr += " <input id='" & drx("Category_ID") & "' type='checkbox' />"
ChildsStr += GetChilds(drx("Category_ID"))
ChildsStr += "</li>" & vbNewLine
Loop
ChildsStr += "</ul>" & vbNewLine
End If
drx.Close()
Return ChildsStr
End Function
it populates good. and I am using this code to retrieve the checkbox value
Dim chk As HtmlControls.HtmlInputCheckBox = CType(Panel1.FindControl("8"), HtmlControls.HtmlInputCheckBox)
Response.Write(chk.Checked)
There is a checkbox with this id "8" I am sure of that.
I am adding the treeview to panel
<asp:Panel ID="Panel1" runat="server"></asp:Panel>
I am getting this error
Object reference not set to an instance of an object.
Please help.
I found a solution. I have added name attribute to the checkbox
<input name='" & drx("Category_ID") & "' id='" & drx("Category_ID") & "' type='checkbox' />
in the button click I used
Reques.form(checkbox name)
See slimmed down code. I'm essentially creating a list of items (printers) along with a dynamically created unique radio button ID, and then I'd like to be able reference said Radio ID in order to toggle the Checked between True/False in Sub SetDefaultPrinter. Why? Because using Add Devices / Search is too hard for some of our users, hence, a cute little GUI. Why dynamic? Because I have multiple separate networks and I'd prefer the script to adjust itself as needed.
<html>
<head>
<title>My HTML application</title>
<HTA:APPLICATION
APPLICATIONNAME="My HTML application"
ID="MyHTMLapplication"
VERSION="1.0"/>
</head>
<script language="VBScript">
Public jj, strPrinters, strModels, strLocations
Sub Window_OnLoad
strPrinters = Array("Printer1", "Printer2")
strModels = Array("HP Color LaserJet 4525", "HP Color LaserJet 4525")
strLocations = Array("Room 1", "Room 2")
jj = UBound(strPrinters)
Call OnClickGo()
End Sub
Sub OnClickGo()
DataArea1.InnerHTML = ""
For i = 0 To jj
DataArea1.InnerHTML = DataArea1.InnerHTML & "<BR><font style=color:green;font-weight=bold;>" &_
"<input type=""" & "radio""" & " name=""" &_
strPrinters(i) & "Radio""" & " id=""" & "Radio" & i & """" &_
" title=""" & "Clicking here will set " & strPrinters(i) & " as default printer.""" &_
" onclick=""" & "SetDefaultPrinter(" & i & ")""" & " onmouseover=""" & "Pointer""" &_
" onmouseout=""" & "DefaultCursor""" & "></input>" &_
"<span id=""" & strPrinters(i) & "Span""" &_
" title=""" & "Click here delete printer mapping for " & strPrinters(i) & """" &_
" onmouseover=""" & "Pointer""" & " onmouseout=""" & "DefaultCursor""" &_
" onclick=""" & "OnClickDelete(" & i & ")""" &_
">" & strPrinters(i) & ", " & strModels(i) & ", Location: " & strLocations(i) & "</span></font>"
Next
End Sub
'========================================
'= Set Default Printer ==================
'========================================
Sub SetDefaultPrinter(ii)
DataArea2.InnerHTML = strPrinters(ii) & " would have been set as default if this was fully functional."
'
' Radio0 and Radio1 are dynamically created IDs, *really* want to somehow
' dynamically reference the dynamically created IDs.
' i.e. something like
' If ii <> 0 Then (Radio & ii).checked = False
'
If ii <> 0 Then Radio0.checked = False
If ii <> 1 Then Radio1.checked = False
End Sub
'========================================
'= Delete Printer Mapping ===============
'========================================
Sub OnClickDelete(ii)
DataArea2.InnerHTML = strPrinters(ii) & " would have been deleted if this was fully functional."
'Set wshnetwork = CreateObject("WScript.Network")
'wshnetwork.RemovePrinterConnection "\\SERVER\" & strPrinters(PrinterToDelete)
End Sub
'========================================
'= MOUSE Pointers =======================
'========================================
Sub Pointer
document.body.style.cursor = "hand"
End Sub
Sub DefaultCursor
document.body.style.cursor = "default"
End Sub
</script>
<body bgcolor="white">
<span id="DataArea1"></span>
<BR><BR><BR>
<span id="DataArea2"></span>
</body>
</html>
user2345916, I have modified your code where the variables pass like you wanted. I left your comments intact, so you can pick up where you left off. Hope this helps!
Basically, the answer to your problem lies within the button's "ID", "VALUE" and "ONCLICK" values.
The ONCLICK='SetDefaultPrinter(" & i & ")' will pass the looped number to the SubRoutine.
The SetDefaultPrinter(Radioii) sets a variable from the "ONCLICK" field of the button that sends you to that SubRoutine (In this case, it's a 0 or 1).
The "FileName = document.getElementById("Radio" & Radioii).value" gets the "VALUE" field of the button that matches the "ID" field that is set between the "()", which in your case is also the variable that was pulled from the ONCLICK.
From here, you can use (FileName) variable to do whatever you want (Match IF/THEN, etc)
<script language=vbscript>
Sub Window_OnLoad
window.resizeTo 500,300
strPrinters = Array("Printer 1", "Printer 2")
strModels = Array("HP Color LaserJet 4525", "HP Color LaserJet 4525")
strLocations = Array("Room 1", "Room 2")
jj = UBound(strPrinters)
For i = 0 To jj
strHTML1 = "<span id='Delete" & i & "' value='" & strPrinters(i) & "'title='Click here delete printer mapping for " & strPrinters(i) & "' onmouseover='Pointer' onmouseout='DefaultCursor' onclick='OnClickDelete(" & i & ")'> " & strPrinters(i) & " - " & strModels(i) & ", Location: " & strLocations(i) & "</span>"
strHTML2 = strHTML2 & "<input type='radio' name='radio' value='" & strPrinters(i) & "' id='Radio" & i & "' title='Clicking here will set " & strPrinters(i) & " as default printer.' onclick='SetDefaultPrinter(" & i & ")' onmouseover='Pointer' onmouseout='DefaultCursor'>" &_
"" & strHTML1 & "</input><br>"
DataArea1.InnerHTML = strHTML2
Next
End Sub
'========================================
'= Set Default Printer ==================
'========================================
Sub SetDefaultPrinter(Radioii)
FileName = document.getElementById("Radio" & Radioii).value
DataArea3.InnerHTML = Filename & " would have been set as default if this was fully functional."
'
' Radio0 and Radio1 are dynamically created IDs, *really* want to somehow
' dynamically reference the dynamically created IDs.
' i.e. something like
' If ii <> 0 Then (Radio & ii).checked = False
'
If Radioii = 0 Then Radio0 = False
If Radioii = 1 Then Radio1 = False
End Sub
'========================================
'= Delete Printer Mapping ===============
'========================================
Sub OnClickDelete(Deleteii)
RemoveName = document.getElementById("Delete" & Deleteii).value
DataArea3.InnerHTML = RemoveName & " would have been deleted if this was fully functional."
'Set wshnetwork = CreateObject("WScript.Network")
'wshnetwork.RemovePrinterConnection "\\SERVER\" & strPrinters(PrinterToDelete)
End Sub
'========================================
'= MOUSE Pointers =======================
'========================================
Sub Pointer
document.body.style.cursor = "hand"
End Sub
Sub DefaultCursor
document.body.style.cursor = "default"
End Sub
</script>
I have written code using asp classic and vb-script in payment.asp. i am posting data to 3rd party using winhttprequest and its submitting successfully and it works fine but my issue is:
after posting data, on 3rd party page, there is creating a unique ID which i want to retrieve on same page payment.asp
how can i retrieve unique ID created by 3rd party.
My code is as below given:
<%
Dim http, url, data
Set http = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
url = "https://www.instamojo.com/api/1.1/payment-requests/"
data = "amount=" & amount & "&buyer_name=" & buyer_name & "&purpose=" & purpose & "&redirect_url=" & redirect_url & "&phone=" & phone & "&send_email=" & send_email & "&send_sms=" & send_sms & "&email=" & email & ""
With http
Call .Open("POST", url, False)
Call .SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
Call .SetRequestHeader("X-Api-Key", "[X-Api-Key]")
Call .SetRequestHeader("X-Auth-Token", "[X-Auth-Token]")
Call .Send(data)
End With
If http.Status = 201 Then
Call Response.Write("succeeded: " & http.Status & " " & http.StatusText)
Else
Call Response.Write("Server returned: " & http.Status & " " & http.StatusText)
End If
%>
please help me.
Apparently the API's results are formatted in JSON. So you'll need a JSON parser like ASPJSON.
Include the aspJSON1.17.asp in your payment.asp and
after getting the response with 201 status code, parse the ID like this:
Set oJSON = New aspJSON
oJSON.loadJSON http.ResponseText
Response.Write oJSON.data("payment_request")("id")
on clicking any row of the following program... I am firing on function mail file click....function just having alert message that shows different file name on the basis of clicking...
****its working properly in IE .....Firefox N other browser function doesnot call on clicking on any row.. whats problem..please help me......i am writing code for your better awareness****
For Each info In fsi
Response.Write("<span id=" & " 'userijd'" & " onmouseup=" & "mailfileclick('" & info.Name & "')" & ";>")
Response.Write("<td width=" & "16%" & " bgcolor=" & "#FFFFFF" & " style=" & "border-bottom-style: solid; border-bottom-width: 1px" & " bordercolor=" & "#C0C0C0" & " nowrap" & ">")
Response.Write("<font face=" & "Arial" & "style=" & "font-size: 9pt" & " color=" & "#000000" & ">" & Mid(contents, InStr(contents, "Date: ") + Len("Date:"), 17) & "</font></td>")
Response.Write("</span>")
Next
this is vbscript code ... i am just calling function mailfileclick ohkkkkkkk
and ohter part this page i am difing function seebelow...
<script type="text/javascript">
function logintk(str) {
alert(str);
}
</script>
i thing ..now you got clear about coding.... one thine more..this code working fine with Internet Exlorer ...problem Firefox and other browser....i think problem area is...
("")
better u know....u r helping hand ...
Firefox (and all other web browsers) don't run VBScript code. For cross-browser compatibility, you should always use JavaScript, not VBScript.