0

我创建了一个搜索 sql 数据库的 aspx 网页,并且该搜索在 gridview 中返回。我正在使用文本框和按钮进行搜索。搜索工作正常,但我试图清除按钮单击时的文本框。

我的cs编码是

using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace OnCallWeb.Sql_Searches
{
    public partial class Plate_Lookup : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ButSearch_Click(object sender, EventArgs e)
        {
            TextBox1.Text = string.Empty;
        }

        protected void ButMaster_Click(object sender, EventArgs e)
        {
            TextBox2.Text = string.Empty;
        }
    }
}```

and my aspx code is 
```                    <span class="auto-style16">&nbsp;&nbsp;</span><asp:Button ID="ButSearch" runat="server" Font-Bold="True" Font-Size="Large" Text="Search" Width="100px" CssClass="auto-style16" OnClick="ButSearch_Click" />
&nbsp;&nbsp; <span class="auto-style16">Enter Master Incident ID:
                    &nbsp;<asp:TextBox ID="TextBox2" runat="server" CssClass="auto-style16"></asp:TextBox>
&nbsp;</span><asp:Button ID="ButMaster" runat="server" Font-Bold="True" Font-Size="Large" Text="Search" Width="100px" />
                <p class="auto-style19" style="text-align: center; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-indent: 0px; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
                    &nbsp;<p class="auto-style19" style="text-align: center; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-indent: 0px; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
                    <strong><span class="auto-style20">Plate Info:</span></strong><div class="auto-style15">
                        <asp:GridView ID="GridView1" runat="server" ShowHeaderWhenEmpty="True" EmptyDataText="No Records Found!" AutoGenerateColumns="False" CssClass="auto-style16" DataSourceID="CADArchive" HorizontalAlign="Center" Font-Size="Medium">
                            <Columns>
                                <asp:BoundField DataField="Master_Incident_ID" HeaderText="Master Incident ID" SortExpression="Master_Incident_ID" />
                                <asp:BoundField DataField="PlateNumber" HeaderText="PlateNumber" SortExpression="PlateNumber" />
                                <asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
                                <asp:BoundField DataField="EntryDate" HeaderText="EntryDate" SortExpression="EntryDate" />
                                <asp:BoundField DataField="UserInitials" HeaderText="UserInitials" SortExpression="UserInitials" />
                            </Columns>

                </asp:GridView>```

When I run the application I am getting an error on the line for <span class="auto-style16">&nbsp;</span><asp:Button ID="ButSearch" runat="server" Font-Bold"True" Font-Size="Large" Text="Search" Width="100px" CssClass="auto-style16" OnClick="ButSearch_Click" />```

I have tried TextBox1.Text = String.Emtpy; and TextBox1.text=""; and neither work.
4

1 回答 1

0

查看标记,我没有看到 Textbox1,而只有 TextBox2?

您发布的标记有误,或者缺少 Textbox2。

使用您给定的标记,然后尝试

TextBox2.Text = "";
于 2021-11-18T00:18:25.537 回答