ASP.NET,创建函数可以直接写在页面里吗?

yingyouzai 2009-04-29 02:28:34
比如 aaa.aspx 这个页面吧,创建函数是写到 aaa.aspx.vb 这样的文件里呢
现在我想知道,能不能直接把函数写到 aaa.aspx 中
我试着不行啊
有没有办法呢
...全文
87 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
CopperBell 2009-04-29
  • 打赏
  • 举报
回复

<script language="C#">
public void Page_Load()
{

}
</script>
yingyouzai 2009-04-29
  • 打赏
  • 举报
回复
明白啦,原来是写到
<script language="VB" runat="server"> 里
写写各位了~
desegou 2009-04-29
  • 打赏
  • 举报
回复
完全可以,例如
<%@page contenttype='text/html'%>
<%@import namespace='system'%>
<%@import namespace='system.data'%>
<%@import namespace='system.data.sqlclient'%>
<%@import namespace='GYTPTQUERY'%>

<script language="VB" runat="server">
dim id as string
dim obj as new DBAct
dim str as string
dim rs As SQLDataReader
dim user as string
dim intype as string
dim goodsno as string
dim srcweight as double
dim db as string
dim owner as string
dim ls_version as string

Function Pre_db(dbv as object) as string
if dbv is dbnull.value
return ""
else
return dbv.tostring()
end if
End Function

Sub Page_load(sender As Object, e As EventArgs)
dim tmp as string

user = GYTCOM.IsLogin()
if trim(user) = "" or user Is Nothing then
user = "guest"
end if
if Not GYTCOM.CheckAuth("","") then
obj.close()
obj=nothing
GYTCOM.ProcError(1)
end if
if request.querystring("ck") is nothing or request.querystring("no") is nothing then
obj.close()
obj=nothing
GYTCOM.ProcError(3)
end if
db = request.querystring("ck")
db = obj.isopened(obj.setsql(db))
if db = "" then
obj.close()
obj=nothing
GYTCOM.ProcError(1)
end if
id = request.querystring("no")
id = obj.setsql(id)

tmp = obj.GetAllowedStoreList(user)
if tmp = "" then
obj.close()
obj=nothing
GYTCOM.ProcError(1)
elseif tmp = "ALL" then
else
if (tmp.IndexOf("'" + obj.GetStoreName(db,4) + "'") < 0) then
obj.close()
obj=nothing
GYTCOM.ProcError(1)
end if
end if
owner = obj.GetAllowedOwnerList(user)

if owner = "" then '没有允许查询的货主
obj.close()
obj=nothing
GYTCOM.ProcError(1)
end if

ls_version = GetVersion()
End Sub

Function GetVersion() as string
dim ls_str as string
str = "select version from t_main_store where db_code = '" + db + "'"
rs = obj.getselect(str)
if rs.read() then
ls_str = rs(0)
else
ls_str = "2"
end if
rs.close()
return ls_str
End Function

</script>

以上代码就是写在aspx里的
harderLi 2009-04-29
  • 打赏
  • 举报
回复
<script language="c#">
函数
</script>
yingyouzai 2009-04-29
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 wangjun8868 的回复:]
可以滴
[/Quote]
怎么写啊?
我写上老是报错
yingyouzai 2009-04-29
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 jingsong2008 的回复:]
aaa.aspx.cs这个文件里,估计是你选择语言时你没有选择默认是VB语言了,而不是C#语言
[/Quote]
我明白这个,我就是不想把函数写到这个 aaa.aspx.cs 里,而是想直接写到 aaa.aspx 中
因为就需要一个文件,而且需要经常改动,所以想直接写到页面里
编程有钱人了 2009-04-29
  • 打赏
  • 举报
回复
可以滴
jingsong2008 2009-04-29
  • 打赏
  • 举报
回复
aaa.aspx.cs这个文件里,估计是你选择语言时你没有选择默认是VB语言了,而不是C#语言

62,268

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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