主题:[讨论]'link.sitename' 不能是零长度的字符串??
[em14][em14]
不知道为什么我做的这个用户控件会出现如标题那样错误~~?
请教下大家~~
6_7.ascx
<%@ Control Language="VB" ClassName="_6_7l" %>
<script runat="server">
Public Property sitenameid() As String
Get
Return sitename.Text
End Get
Set(ByVal value As String)
sitename.Text = value
End Set
End Property
Public Property urlid() As String
Get
Return url.text
End Get
Set(ByVal value As String)
url.text = value
End Set
End Property
Public Property introduceid() As String
Get
Return siteintroduce.Text
End Get
Set(ByVal value As String)
siteintroduce.Text = value
End Set
End Property
Public Property scoreid() As String
Get
Return sitescore.Text
End Get
Set(ByVal value As String)
sitescore.Text = value
End Set
End Property
</script>
<table align=center style="width: 420px">
<tr>
<td style="width: 89px">
网站名称:</td>
<td style="width: 120px">
<asp:TextBox ID="sitename" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 89px">
网站地址:</td>
<td style="width: 120px">
<asp:TextBox ID="url" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 89px">
网站简介:</td>
<td style="width: 120px">
<asp:TextBox ID="siteintroduce" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 89px">
网站评分:</td>
<td style="width: 120px">
<asp:DropDownList ID="sitescore" runat="server">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList></td>
</tr>
<tr>
<td style="width: 89px">
</td>
<td style="width: 120px">
<asp:Button ID="Button1" runat="server" Text="提交" /></td>
</tr>
</table>
6_7.aspx的程序见下面~~
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ register tagprefix="mycontrol" TagName="login" Src="6_7.ascx"%>
<%@ Page Language="VB" %>
<script runat="server">
Sub page_load(ByVal sender As Object, ByVal e As EventArgs)
'建立Connection对象
Dim s1, strconn As String
s1 = Server.MapPath("wwwlink.mdb")
strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & s1
Dim conn As New OleDbConnection(strconn)
'代替Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("wwwlink.mdb"))
'建立Command对象
Dim cmd As New OleDbCommand("Insert Into link(sitename,URL,intro,grade,submit_date) Values('" & mylogin.sitenameid & "','" & mylogin.urlid & "','" & mylogin.introduceid & "','" & CInt(mylogin.scoreid) & "',#" & Now() & "#)", conn)
'执行操作,插入记录
conn.open() '打开数据库
cmd.ExecuteNonQuery()
conn.close() '关闭数据库
message.Text = "已经成功添加,请自己打开数据库wwwlink.mdb查看结果"
End Sub
</script>
<html>
<head runat="server">
<title>用户控件</title>
</head>
<body>
<form id="form1" runat="server">
<mycontrol:login ID="mylogin" runat="server"/>
<asp:Label ID="message" runat="server" Text="show"></asp:Label>
</form>
</body>
</html>
有什么错误的地方请大家多多指教~~~谢谢了
不知道为什么我做的这个用户控件会出现如标题那样错误~~?
请教下大家~~
6_7.ascx
<%@ Control Language="VB" ClassName="_6_7l" %>
<script runat="server">
Public Property sitenameid() As String
Get
Return sitename.Text
End Get
Set(ByVal value As String)
sitename.Text = value
End Set
End Property
Public Property urlid() As String
Get
Return url.text
End Get
Set(ByVal value As String)
url.text = value
End Set
End Property
Public Property introduceid() As String
Get
Return siteintroduce.Text
End Get
Set(ByVal value As String)
siteintroduce.Text = value
End Set
End Property
Public Property scoreid() As String
Get
Return sitescore.Text
End Get
Set(ByVal value As String)
sitescore.Text = value
End Set
End Property
</script>
<table align=center style="width: 420px">
<tr>
<td style="width: 89px">
网站名称:</td>
<td style="width: 120px">
<asp:TextBox ID="sitename" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 89px">
网站地址:</td>
<td style="width: 120px">
<asp:TextBox ID="url" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 89px">
网站简介:</td>
<td style="width: 120px">
<asp:TextBox ID="siteintroduce" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 89px">
网站评分:</td>
<td style="width: 120px">
<asp:DropDownList ID="sitescore" runat="server">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList></td>
</tr>
<tr>
<td style="width: 89px">
</td>
<td style="width: 120px">
<asp:Button ID="Button1" runat="server" Text="提交" /></td>
</tr>
</table>
6_7.aspx的程序见下面~~
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ register tagprefix="mycontrol" TagName="login" Src="6_7.ascx"%>
<%@ Page Language="VB" %>
<script runat="server">
Sub page_load(ByVal sender As Object, ByVal e As EventArgs)
'建立Connection对象
Dim s1, strconn As String
s1 = Server.MapPath("wwwlink.mdb")
strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & s1
Dim conn As New OleDbConnection(strconn)
'代替Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("wwwlink.mdb"))
'建立Command对象
Dim cmd As New OleDbCommand("Insert Into link(sitename,URL,intro,grade,submit_date) Values('" & mylogin.sitenameid & "','" & mylogin.urlid & "','" & mylogin.introduceid & "','" & CInt(mylogin.scoreid) & "',#" & Now() & "#)", conn)
'执行操作,插入记录
conn.open() '打开数据库
cmd.ExecuteNonQuery()
conn.close() '关闭数据库
message.Text = "已经成功添加,请自己打开数据库wwwlink.mdb查看结果"
End Sub
</script>
<html>
<head runat="server">
<title>用户控件</title>
</head>
<body>
<form id="form1" runat="server">
<mycontrol:login ID="mylogin" runat="server"/>
<asp:Label ID="message" runat="server" Text="show"></asp:Label>
</form>
</body>
</html>
有什么错误的地方请大家多多指教~~~谢谢了