首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

|M| 在页面中aspx里面写程序的时候如何写上方法

2012-01-18 
|M| 在页面中aspx里面写程序的时候怎么写上方法啊PublicSharedFunctionGetMD5(ByValEnDataAsString)AsStri

|M| 在页面中aspx里面写程序的时候怎么写上方法啊
Public   Shared   Function   GetMD5(ByVal   EnData   As   String)   As   String
...
End   Function

如上面是转MD5的
现在我在aspx里面写
<%
Public   Shared   Function   GetMD5(ByVal   EnData   As   String)   As   String
...
End   Function
Dim   UnData=GetMd5( "123 ");
%>
上面这个要怎么改才能运行

[解决办法]
<%@ Page Language= "VB " %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<script runat= "server ">

Public Shared Function GetMD5(ByVal EnData As String) As String
...
End Function
</script>

<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> Untitled Page </title>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<asp:Button ID= "Button1 " runat= "server " OnClick= "Button1_Click " Text= "Button " /> </div>
</form>
</body>
</html>

[解决办法]
<%@ Page Language= "VB " %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<script runat= "server ">
Public Shared Function GetMD5(ByVal EnData As String) As String
GetMD5 = "abc "
End Function
Dim UnData = GetMD5( "123 ")
</script>

<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> 无标题页 </title>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
</div>
</form>
</body>
</html>
[解决办法]
<script runat= "server "> Public Shared Function GetMD5(ByVal EnData As String) As StringGetMD5 = "abc "End FunctionDim UnData = GetMD5( "123 ")Sub Page_Load()Response.Write(UnData) End Sub </script>

热点排行