Error Code
Master. Master slave ---------------------------------------------------------------------------------------------
<% @ Master Language = "C #" AutoEventWireup = "true" CodeFile = "master. master. cs"
Inherits = "master_master" %>
<! 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> test </title>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Asp: ContentPlaceHolder ID = "ContentPlaceHolder1" runat = "server">
</Asp: ContentPlaceHolder>
</Form>
</Body>
</Html>
InMasterPage. aspx plugin ---------------------------------------------------------------------------------------
<% @ Page Language = "C #" MasterPageFile = "~ /Master. master "AutoEventWireup =" true"
CodeFile = "Order. aspx. cs" Inherits = "InMasterPage_Order" %>
<Asp: Content ID = "Content1" ContentPlaceHolderID = "ContentPlaceHolder1" runat = "Server">
<Table cellpadding = "0" cellspacing = "0" border = "0" width = "100%">
<Tr align = "left" valign = "top">
<Td style = "width: 40%;">
<Asp: SqlDataSource ID = "SqlDataSourceTicketInfo" runat = "server" ConnectionString = "<% $ ConnectionStrings: YinYeTravelConnectionString %>"
SelectCommand = "* WHERE ([OperationID] = @ OperationID)">
<SelectParameters>
<Asp: QueryStringParameter Name = "OperationID" QueryStringField = "ID" Type = "Int32"/>
</SelectParameters>
</Asp: SqlDataSource>
<Div id = "OrderInfo" runat = "server">
<Asp: DetailsView ID = "DetailsView1" runat = "server" AutoGenerateRows = "False" BackColor = "White"
BorderColor = "#336666" BorderStyle = "Double" BorderWidth = "3px" CellPadding = "4"
DataKeyNames = "OperationID" DataSourceID = "SqlDataSourceTicketInfo" GridLines = "Horizontal"
HeaderText = "**" HorizontalAlign = "Center" Width = "300px">
<FooterStyle BackColor = "White" ForeColor = "#333333"/>
<EditRowStyle BackColor = "#339966" Font-Bold = "True" ForeColor = "White"/>
<RowStyle BackColor = "White" ForeColor = "#333333"/>
<PagerStyle BackColor = "#336666" ForeColor = "White" HorizontalAlign = "Center"/>
<Fields>
<Asp: BoundField DataField = "OperationID" HeaderText = "OperationID" InsertVisible = "False"
ReadOnly = "True" SortExpression = "OperationID"/>
<Asp: BoundField [other bindings, Here omitted]/>
</Fields>
<HeaderStyle BackColor = "#00C000" Font-Bold = "True" ForeColor = "White"/>
</Asp: DetailsView>
</Div>
</Td>
<Td style = "width: 60%;">
</Td>
</Tr>
</Table>
</Asp: Content>
InMasterPage. aspx. cs -------------------------------------------------------------------------------
System. IO. StringWriter sw = new System. IO. StringWriter ();
HtmlTextWriter htw = new HtmlTextWriter (sw );
DetailsView1.RenderControl (htw );
The error message "XX" indicates that the control "XX" of "type" XX "must be placed in the form tag with runat = server"
I have encountered this problem before, probably because my control is no longer in the Form label. But here we are.
Well, I cannot explain it clearly.
So I found Msdn to see which method is reporting an error, and finally found the VerifyRenderingInServerForm method. Fortunately, this method supports rewriting, so I added it to the page with a try attitude.
Public override void VerifyRenderingInServerForm (Control control Control)
{
// Base. VerifyRenderingInServerForm (control );
}
Test passed. I don't know why.
It seems that there is no reason, but this can only be done for the time being. You can check it out later!