为什么呢?新手求助
新手求助!
我打开一个aspx页面源文件(源码附后面),想在浏览器里运行看看,但是报告错误:
C:\guest\Leave.aspx(1,29):error CS0029:无法将类型"string"隐式转换为"System.Web.UI.WebControls.TextBox"
我在网上查了大半天了,但是网上情况跟我的好像不一样.网上说是因为TextBox.text没赋值。但我没有赋值给TextBox啊,我是只是把TextBox的内容body,Title绑定了而已。
再补充一点情况,供参考。我看这个错误提示是指向1行,29列,但是那个位置是"MasterPageFile....."这句话 ,我想应该不是它的问题。后来我反正也没办法,干脆把MasterPageFile="~/Common/MasterPage.master" 这句也删了,但是错误一样:
C:\guest\Leave.aspx(1,29):error CS0029:无法将类型"string"隐式转换为"System.Web.UI.WebControls.TextBox"。
还是在1行,29列。然后我就倒了。。
下面是源码,有些我注释掉了:
<%@ Page Language="C#" MasterPageFile="~/Common/MasterPage.master" AutoEventWireup="true" CodeFile="LeaveBoard.aspx.cs" Inherits="Guest_LeaveBoard" Title="Untitled Page" %>
<%@ Register Src="../Common/TreeMovie.ascx" TagName="TreeMovie" TagPrefix="uc1" %>
<%@ Register TagPrefix="webdiyer" Namespace="Wuqi.Webdiyer" Assembly="AspNetPager" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div>
<table style="width: 100%;">
<tr>
<td colspan=3 style="height: 20px">
<span style="font-size: 14pt;"><asp:Label ID="Label3" runat="server" Width="400px">留言</asp:Label></span>
</tr>
<tr>
<td style="width:15px">
</td>
<td style="width: 130px" class="h2">
<uc1:TreeMovie ID="TreeMovie1" runat="server" />
</td>
<td style="width:520px;">
<asp:Panel ID="Panel1" runat="server" Height="400px" Width="520px" ScrollBars="Vertical">
<form id="form1" runat="server">
<table style="width:520px;table-layout:fixed" align="center">
<tr>
<td><font size="4">用户留言:</font></td><td align="right">
</tr>
<tr>
<td colspan="2">
<asp:GridView ID="LeaveBoardList" DataSourceID="srcLeaveBoard" CellPadding="4" CssClass="GbText" runat="server" AutoGenerateColumns="False" ShowHeader="False" Width="100%" ForeColor="#333333" GridLines="None" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<tr>
<td height="30" style="font-weight: bold; border-bottom: Wheat thin solid;">主题:<%# DataBinder.Eval(Container.DataItem,"Title") %></td>
</tr>
<tr>
<td><br /> <%# FormatBody((String)DataBinder.Eval(Container.DataItem,"Body")) %></td>
</tr>
<%--
<tr>
<td align="left" style="width:100%"><br />
<asp:Panel ID="ReplyPanel" Visible='<%# IsShowReply %>' runat="server" Width="100%"><asp:Label ID="White" runat="server" Width="50">
</asp:Label><font color="#FFD700">留言回复:<br /></font><asp:Label ID="Label1" runat="server" Width="50"></asp:Label><font color="green" ><%# DataBinder.Eval(Container.DataItem,"ReplyBody") %></font></asp:Panel><br />
</td>
</tr>
--%>
<tr>
<td align="right" style="width: 100%; position: static;">
<font class=gbtext color=gold>留言时间:<%# DataBinder.Eval(Container.DataItem,"CreateTime") %>
</font>
</td>
</tr>
<%-- </table> --%>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="White" />
<EditRowStyle BackColor="#7C6F57" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#66666" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</td>
</tr>
</table>
<table width="100%" align="center" style="background-color: #E3EAEB;" >
<tr>
<td width="100%"><font color=#FFD700>IP地址:(<%=IPAddress%>)</font></td>
</tr>
<tr>
<td style="height: 48px"><font color=#FFD700>留言主题:</font>
<br>
<asp:Textbox id="Title" Runat="server" CssClass="InputCss" Width="300px"></asp:textbox>
<font class="GbText" color="red">*</font><asp:RequiredFieldValidator id="rfTitle" runat="server" ErrorMessage="(主题不能为空!!!)" ControlToValidate="Title"
CssClass="GbText"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td><font class="Normal" color=#FFD700>留言内容(内容的长度大于10!):</font>
<br>
<asp:TextBox ID="Body" CssClass="InputCss" Runat="server" TextMode="MultiLine" Width="400px" Height="200px"></asp:TextBox>
</td>
</tr>
</table>
<table width="100%" align="center" style="background-color: #E3EAEB;">
<tr>
<td align="center" width="400"><br>
<asp:Button ID="SureBtn" Runat="server" CssClass="ButtonCss" Text="我要留言" Width="200px" OnClick="SureBtn_Click"></asp:Button>
<br>
</td>
</tr>
</table>
</form>
</asp:Panel>
</td>
</tr>
</table>
</div>
</asp:Content>
请问各位有没遇到过这种情况,该怎么解决呢?有什么思路也可以说出来,谢谢。
这么晚了都,大家都睡了吧。。。Good night.今天晚点再来看看。