如何在后台vb.net程序中调用前台jsp的一个函数(附代码)

foxmayfly 2003-08-31 10:50:27
如何在后台vb.net程序中调用前台jsp的一个函数

html中:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="UploadFiles.aspx.vb" Inherits="WebFreeTextVb.UploadFiles"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>选择要插入的图片</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="UploadFiles" method="post" action="UploadFiles.aspx" enctype="multipart/form-data" runat="server">
<table>
<tr>
<td>
请选择要上传的图片:</td>
<td><input id="uplTheFile" type="file" name="uplTheFile" runat="server"></td>
<tr>
<td colSpan="2"><asp:button id="btnUploadTheFile" runat="server" Text="上传" Width="62px"></asp:button>
<asp:Label id="txtErrMsg" runat="server" ForeColor="Red" Visible="False"></asp:Label></td>
</tr>
</table>
<HR id="null" SIZE="1">
<br>
<asp:placeholder id="imageOutput" Runat="server"></asp:placeholder>
</form>
<SCRIPT language="javascript">
function returnImage(imagename,width,height) {
var arr = new Array();
arr["filename"] = imagename;
arr["width"] = width;
arr["height"] = height;
window.parent.returnValue = arr;
window.parent.close();
}
</SCRIPT>
</body>
</HTML>

vb.net中(部分代码)
Private Sub ListImages()
'initialize control
imageOutput.Controls.Clear()
Dim strUploadPath As String = "UpImages"
Dim strDirectory As String = Server.MapPath("~/" + strUploadPath)
Dim dir As DirectoryInfo = New DirectoryInfo(strDirectory)
Dim enTry As FileSystemInfo
For Each enTry In dir.GetFileSystemInfos()
Dim tem As String = System.IO.Path.GetExtension(enTry.Name).ToLower()
If (tem = ".gif") Or (tem = ".jpg") Then
Dim image1 As HtmlImage = New HtmlImage()
image1.Src = "~/" + strUploadPath + "/" + enTry.Name
'image1.Height=100;
image1.Border = 1

'image1.Attributes.Add("onclick","javascript:window.returnValue ='" + strUploadPath + "/" + entry.Name +"';" +" window.close();");
imageOutput.Controls.Add(image1)
'image1.Attributes["ondblclick"]="returnImage('" + strUploadPath + "/" + "','" + image1.Width.ToString() + "','" + image1.Height.ToString() + "');";
image1.Attributes("ondblclick") = "returnImage('" + strUploadPath + "/" + enTry.Name + "','" + 100 + "','" + 100 + "');"
'修改 image1.Attributes("ondblclick") = "returnImage(" +100 + "," + 100 + ");"
'修改 image1.Attributes("ondblclick") = "returnImage(" + strUploadPath + "/" + enTry.Name + "," + 100 + "," + 100 + ");"

End If
Next
End Sub
...全文
160 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
foxmayfly 2003-08-31
  • 打赏
  • 举报
回复
谢谢 cnhgj,果然对了
cnhgj 2003-08-31
  • 打赏
  • 举报
回复
这样

image1.Attributes("onclick") = "returnImage('" & strUploadPath & "/" & enTry.Name
& "','100','100');"
cnhgj 2003-08-31
  • 打赏
  • 举报
回复
image1.Attributes("onclick") = "returnImage('" & strUploadPath & "/" & enTry.Name & "','" & 100 & "','" & 100 & "');"
foxmayfly 2003-08-31
  • 打赏
  • 举报
回复
出错信息是:输入的字符串的格式不正确
错在
image1.Attributes("ondblclick") = "returnImage('" + strUploadPath + "/" + enTry.Name + "','" + 100 + "','" + 100 + "');"

堆栈跟踪
InvalidCastException:从字符串"returnImage('UpImage/1.jpg','"到类型"Double"的强制转换无效。

我不太懂jsp
不知道这个格式怎么写
原先在c#的代码中,这样写是对的,可是转为VB.net后就出错了
popcorn 2003-08-31
  • 打赏
  • 举报
回复
jsp?
是JS脚本吧?
你将需要调用的变量或涵数声明为protected或者public类型就可以直接使用了.

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧