asp.net(vb)问题

xayzmb 2009-10-20 03:45:18
login.aspx.vb:

Public ReadOnly Property nameT() As String
Get
Return TextBox1.Text
End Get
End Property


Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Server.Transfer("webTop.aspx")
End Sub


webTop.aspx.vb:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim w As Login
w = CType(Context.Handler, Login) <------运行到这里报错

End Sub


错误提示:
无法将类型为“ASP.login_aspx”的对象强制转换为类型“System.Web.UI.WebControls.Login”。
...全文
71 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
xayzmb 2009-10-20
  • 打赏
  • 举报
回复
有人会吗?
xayzmb 2009-10-20
  • 打赏
  • 举报
回复
我是按照下面的代码写的
但总是报错

-------------------------------------------------------------------------------
使用Server.Transfer方法把流程从当前页面引导到另一个页面中,新的页面使用前一个页面的应答流,所以这个方法是完全面象对象的,简洁有效。

a.aspx的VB.NET代码

Public ReadOnly Property Name() As String
Get
Return Label1.Text
End Get
End Property
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Server.Transfer("b.aspx")
End Sub

b.aspx中VB.NET代码
Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim NewWeb As a '实例a窗体
NewWeb = CType(Context.Handler, source)
Dim name As String
name = NewWeb.Name
End Sub


-------------------------------------------------------------------------------
xayzmb 2009-10-20
  • 打赏
  • 举报
回复
按楼上的写法不报错了
但也取不到nameT的值
zhouyanfss 2009-10-20
  • 打赏
  • 举报
回复
CType(Context.Handler, Login)==》CType(Context.Handler, Page)
zhouyanfss 2009-10-20
  • 打赏
  • 举报
回复
Dim w As Login ==》Dim w As Page
试试
这是第六版的介绍《ASP.NET 4入门经典:涵盖C#和VB.NET(第6版)》内容简介:ASP.NET是.NET Framework的一部分,用于构建内容丰富的动态Web站点。其最新的版本ASP.NET 4对上一版进行了许多改进,包括增强了Web窗体,并添加了jQuery的支持。《ASP.NET 4入门经典:涵盖C#和VB.NET(第6版)》循序渐进,逐步讲解了如何使用ASP.NET 4构建内容丰富的Web站点,并提供了大量使用C#和VB的示例。通过实际动手练习,您将学到关于构建Web站点的第一手信息,同时能够深刻理解在浏览器中查看ASP.NET 4页面时,后台到底发生了什么。 这是第七版,也就是本源码书的介绍 The ultimate programming guide to ASP.NET 4.5, by popular author and Microsoft MVP Imar Spaanjaars Updated for ASP.NET 4.5, this introductory book is filled with helpful examples and contains a user-friendly, step-by-step format. Written by popular author and Microsoft ASP.NET MVP Imar Spaanjaars, this book walks you through ASP.NET, Microsoft's technology for building dynamically generated web pages. This edition retains the highly accessible approach to building the Planet Wrox website example, an online community site featuring product reviews, picture sharing, bonus content for registered users, and more. Contains the comprehensive guide to the latest technology additions to ASP.NET 4.5 Shows how to build basic ASP.NET web pages and configure their server Includes information on how to add features with pre-built server controls Reveals how to design pages and make them consistent Contains the information needed for getting user input and displaying data Beginning ASP.NET 4.5 in C# and VB uses Spaanjaars's distinct writing style to put you at ease with learning ASP.NET 4.5.

16,722

社区成员

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

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