将文本框输入发送到ASP

将文本框输入发送到ASP

本文介绍了将文本框输入发送到ASP.NET中的Visual Basic字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个ASP页面上,该页面将按标题,作者,主题或关键字搜索一本书.我创建了变量来保存信息,但是在调试页面时,我得到了NullReferenceException:

对象引用未设置为对象的实例

您如何将字符串引用到文本框?我还应该对变量做些什么?希望此修改后的代码有帮助.

I''m working on an ASP page that will search for a book by title, author, subject, or keywords. I created variables to hold the information, but when I debug the page, I get a NullReferenceException:

Object reference not set to an instance of an object

How do you reference a string to a textbox? What else should I do to my variables? I hopethis revised code helps.

Public Class Search
	Inherits System.Web.UI.Page

	Dim strTitle As String = Me.TB_Title.Text
	Dim strAuthor As String = Me.TB_Author.Text
	Dim strSubject As String = Me.TB_Subject.Text
	Dim strKeywords As String = Me.TB_Keyword.Text

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

	End Sub

	Protected Sub BTN_Submit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles BTN_Submit.Click
		If TB_Title.Text = "" And TB_Author.Text = "" And TB_Subject.Text = "" And TB_Keyword.Text = "" Then
			CV_BlankField.Visible = True
		Else
			CV_BlankField.Visible = False
		End If
	End Sub

	Protected Sub BTN_Clear_Click(ByVal sender As Object, ByVal e As EventArgs) Handles BTN_Clear.Click
		strTitle = ""
		strAuthor = ""
		strSubject = ""
		strKeywords = ""
	End Sub
End Class

推荐答案


这篇关于将文本框输入发送到ASP.NET中的Visual Basic字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 06:39