开发者

why don't recognize the textfield and the button like component's asp

i have in my code a table with a text field and a button on each cell. My problem it's that the button and the field are not recognized like System.Web.UI.WebControls.Button and System.Web.UI.WebControls.TextBox respectively. In fact recognize like buton are textfield html plain. I'm going to put my code so if anybody can see what i'm doing wrong.

Note: If i put this elemets out of the table work so i assumed that something wrong in the table

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MapaPrueba._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">开发者_如何转开发
<title>Uso de google map</title>
     <link href='/assets/css/styles.css' rel='stylesheet' type='text/css' />
</head>
<body>
<form id="form1" runat="server">
<asp:Panel runat="server" Height="1024" Width="768" style="text-align: center"> 
<div id="map-canvas" style="width: 700px; height: 500px" align="center"></div>                     
<asp:Table id="Table1" runat="server" CellPadding="10" GridLines="Both" HorizontalAlign="Center">
    <asp:TableRow runat="server">
        <asp:TableCell runat="server">
            <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
        </asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="TextBox1" runat="server" ></asp:TextBox>
        </asp:TableCell>
    </asp:TableRow>
</asp:Table>
</asp:Panel>
</form>
</body>
</html>


I would follow atrljoe's suggestion. Don't use an asp table, just use

<table> <tr> <td> controls go here </td> <tr> </table>

Tip: If you add the table first, switch in VS to Design View and using Ctrol + Alt + arrows you can add new rows and columns easily


You cant access the controls because your placing a Control (ASP Button & ASP TextBox) within a Control (ASP Table) ASP.NET Table. Every ASP.net page has a control tree, all the controls (HTML and server controls are in this control tree based on their position in page hierarchy). Thus since it is contained within the Control, the system is not picking it up. To gain access to this control you would need to use FindControl in your code behind.

As I had asked, If you really need to control this button and textbox, then consider changing to an HTML table. Otherwise when you reference these controls in your code behind you will need to use FindControl

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜