Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Webform Error w/ Buttons 1

Status
Not open for further replies.

Compkitty

Programmer
Jan 7, 2005
121
US
I have a page w/ a Data grid and some other random controls(txtboxes, labels, usercontrol)
Well I have two buttons
1. print
2. export to excel

and I'm getting the following error
Also, it's stating that the txtdueDate is outside of the form tag, but it isn't and is part of my Datagrid.. (template column)



Code:
Control 'Dg__ctl2_txtDueDate' of type 'TextBox' must be placed inside a form tag with runat=server. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: Control 'Dg__ctl2_txtDueDate' of type 'TextBox' must be placed inside a form tag with runat=server.

Source Error: 

Line 126:        DgPrint.GridLines = GridLines.Both
Line 127:        DgPrint.HeaderStyle.Font.Bold = True
(it's on this line):
Line 128:        DgPrint.RenderControl(htmlWrite)
Line 129:        Response.Write(stringWrite.ToString)
Line 130:        Response.End()

Source File: c:\inetpub\[URL unfurl="true"]wwwroot\GenX\MyClients.aspx.vb[/URL]    Line: 128 

Stack Trace: 

[HttpException (0x80004005): Control 'Dg__ctl2_txtDueDate' of type 'TextBox' must be placed inside a form tag with runat=server.]
   System.Web.UI.Page.VerifyRenderingInServerForm(Control control)
   System.Web.UI.WebControls.TextBox.AddAttributesToRender
(HtmlTextWriter writer)
   System.Web.UI.WebControls.WebControl.RenderBeginTag
(HtmlTextWriter writer)
   System.Web.UI.WebControls.TextBox.Render(HtmlTextWriter writer)
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   System.Web.UI.Control.Render(HtmlTextWriter writer)
   System.Web.UI.WebControls.WebControl.RenderContents
(HtmlTextWriter writer)
   System.Web.UI.WebControls.TableCell.RenderContents
(HtmlTextWriter writer)
   System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   System.Web.UI.Control.Render(HtmlTextWriter writer)
   System.Web.UI.WebControls.WebControl.RenderContents
(HtmlTextWriter writer)
   System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   System.Web.UI.WebControls.Table.RenderContents(HtmlTextWriter writer)
   System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   System.Web.UI.Control.Render(HtmlTextWriter writer)
   System.Web.UI.WebControls.WebControl.RenderContents
(HtmlTextWriter writer)
   System.Web.UI.WebControls.BaseDataList.Render
(HtmlTextWriter writer)
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   GenX.WebForm2.BtnExport_Click(Object sender, 
EventArgs e) in c:\inetpub\[URL unfurl="true"]wwwroot\GenX\MyClients.aspx.vb:128[/URL]
   System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   System.Web.UI.WebControls.Button.System.Web.UI.
IPostBackEventHandler.
RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent
(NameValueCollection postData)
   System.Web.UI.Page.ProcessRequestMain()

Any ideas. I was able to stop it, but now it's back and i'm not sure why now... I haven't really changed anything...
 
The error is telling you that the textbox named "Dg__ctl2_txtDueDate" is outside of the <form> tag. I would check your HTML code and see why.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
i.e. is there one and only one starting and end <form> tag with the runat=server attribute?

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Yes there is one and only one <form> (starting & ending) w/ the runat=server....

 
Can you paste the HTML code you are using (assuming it is not excessively long!)?

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
It's pretty long; is there a way I can attach it? or cut out what is needed to be viewed???
 
I was just going to have a quick look through to see if there seemed to be any rogue opening/closing tags. You may as well just post it anyway (unless you have access to a server that could host a text file of it for you?).

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Ok, Here you go... THANKs


Code:
&lt;%@ Page Language=&quot;vb&quot; AutoEventWireup=&quot;false&quot; Codebehind=&quot;MyClients.aspx.vb&quot; Inherits=&quot;GenX.WebForm2&quot; EnableSessionState=true %&gt;
&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;&gt;
&lt;HTML&gt;
	&lt;HEAD&gt;
		&lt;title&gt;My Clients Page&lt;/title&gt;
		&lt;meta content=&quot;Microsoft Visual Studio .NET 7.1&quot; name=&quot;GENERATOR&quot;&gt;
		&lt;meta content=&quot;Visual Basic .NET 7.1&quot; name=&quot;CODE_LANGUAGE&quot;&gt;
		&lt;meta content=&quot;JavaScript&quot; name=&quot;vs_defaultClientScript&quot;&gt;
		&lt;meta content=&quot;[URL unfurl="true"]http://schemas.microsoft.com/intellisense/ie5&quot;[/URL] name=&quot;vs_targetSchema&quot;&gt;
	&lt;/HEAD&gt;
	&lt;body MS_POSITIONING=&quot;GridLayout&quot;&gt;
		&lt;form id=&quot;Form1&quot; method=&quot;post&quot; runat=&quot;server&quot;&gt;
			&lt;asp:panel id=&quot;PRptQtr&quot; style=&quot;Z-INDEX: 102; LEFT: 576px; POSITION: absolute; TOP: 224px&quot; runat=&quot;server&quot;
				Width=&quot;517px&quot; Height=&quot;56px&quot; BorderColor=&quot;Navy&quot; BorderStyle=&quot;Solid&quot; Font-Size=&quot;Large&quot;&gt;
				&lt;P style=&quot;LINE-HEIGHT: 6pt&quot;&gt; &lt;/P&gt;
				&lt;P style=&quot;LINE-HEIGHT: 6pt&quot;&gt;               
					Report Production for Quarter Ending&lt;/P&gt;
			&lt;/asp:panel&gt;&lt;asp:button id=&quot;BtnOk&quot; style=&quot;Z-INDEX: 118; LEFT: 808px; POSITION: absolute; TOP: 192px&quot; runat=&quot;server&quot;
				Width=&quot;116px&quot; Height=&quot;24px&quot; BorderStyle=&quot;Outset&quot; Font-Size=&quot;X-Small&quot; Text=&quot;Update&quot;&gt;&lt;/asp:button&gt;&lt;asp:label id=&quot;lblArr1&quot; style=&quot;Z-INDEX: 111; LEFT: 64px; POSITION: absolute; TOP: 128px&quot; runat=&quot;server&quot;
				Width=&quot;8px&quot; BackColor=&quot;#99CC00&quot; ForeColor=&quot;White&quot;&gt;&gt;&lt;/asp:label&gt;&lt;asp:button id=&quot;btnPrint&quot; style=&quot;Z-INDEX: 108; LEFT: 936px; POSITION: absolute; TOP: 192px&quot;
				runat=&quot;server&quot; Width=&quot;116px&quot; Height=&quot;24px&quot; BorderStyle=&quot;Outset&quot; Font-Size=&quot;X-Small&quot; Text=&quot;Print Client List&quot;&gt;&lt;/asp:button&gt;&lt;asp:button id=&quot;BtnView&quot; style=&quot;Z-INDEX: 107; LEFT: 536px; POSITION: absolute; TOP: 168px&quot; runat=&quot;server&quot;
				Width=&quot;192px&quot; Height=&quot;48px&quot; BorderStyle=&quot;Outset&quot; Text=&quot;View Quarterly Recon Stats&quot;&gt;&lt;/asp:button&gt;&lt;asp:panel id=&quot;Panel2&quot; style=&quot;Z-INDEX: 104; LEFT: 576px; POSITION: absolute; TOP: 288px&quot; runat=&quot;server&quot;
				Width=&quot;517px&quot; Height=&quot;33px&quot; BorderColor=&quot;#99CC00&quot; BorderStyle=&quot;Solid&quot;&gt;  &lt;/asp:panel&gt;&lt;asp:panel id=&quot;PQtrend1&quot; style=&quot;Z-INDEX: 103; LEFT: 32px; POSITION: absolute; TOP: 288px&quot; runat=&quot;server&quot;
				Width=&quot;360px&quot; Height=&quot;33px&quot; BorderColor=&quot;#99CC00&quot; BorderStyle=&quot;Solid&quot;&gt; 
 
   For Month Ending:  &lt;/asp:panel&gt;&lt;asp:panel id=&quot;PClient&quot; style=&quot;Z-INDEX: 100; LEFT: 32px; POSITION: absolute; TOP: 224px&quot; runat=&quot;server&quot;
				Width=&quot;360px&quot; Height=&quot;56px&quot; BorderColor=&quot;Navy&quot; BorderStyle=&quot;Solid&quot; Font-Size=&quot;X-Large&quot;&gt;             
My Clients &lt;/asp:panel&gt;&lt;asp:panel id=&quot;PMthlyRecon&quot; style=&quot;Z-INDEX: 101; LEFT: 408px; POSITION: absolute; TOP: 224px&quot;
				runat=&quot;server&quot; Width=&quot;152px&quot; Height=&quot;56px&quot; BorderColor=&quot;Navy&quot; BorderStyle=&quot;Solid&quot; Font-Size=&quot;Medium&quot;&gt;
				&lt;P style=&quot;LINE-HEIGHT: 6pt&quot;&gt;  
				&lt;/P&gt;
				&lt;P style=&quot;LINE-HEIGHT: 6pt&quot;&gt;   Monthly Recon&lt;/P&gt;
			&lt;/asp:panel&gt;&lt;asp:dropdownlist id=&quot;DlistDate&quot; style=&quot;Z-INDEX: 105; LEFT: 408px; POSITION: absolute; TOP: 296px&quot;
				runat=&quot;server&quot; Width=&quot;152px&quot; Height=&quot;50px&quot; AutoPostBack=&quot;True&quot;&gt;
				&lt;asp:ListItem Value=&quot;1/31/2004&quot;&gt;1/31/2004&lt;/asp:ListItem&gt;
				&lt;asp:ListItem Value=&quot;2/29/2004&quot;&gt;2/29/2004&lt;/asp:ListItem&gt;
				&lt;asp:ListItem Value=&quot;3/31/2004&quot;&gt;3/31/2004&lt;/asp:ListItem&gt;
				&lt;asp:ListItem Value=&quot;4/30/2004&quot;&gt;4/30/2004&lt;/asp:ListItem&gt;
				&lt;asp:ListItem Value=&quot;5/31/2004&quot;&gt;5/31/2004&lt;/asp:ListItem&gt;
				&lt;asp:ListItem Value=&quot;6/30/2004&quot;&gt;6/30/2004&lt;/asp:ListItem&gt;
				&lt;asp:ListItem Value=&quot;7/31/2004&quot;&gt;7/31/2004&lt;/asp:ListItem&gt;
				&lt;asp:ListItem Value=&quot;8/31/2004&quot;&gt;8/31/2004&lt;/asp:ListItem&gt;
				&lt;asp:ListItem Value=&quot;9/30/2004&quot;&gt;9/30/2004&lt;/asp:ListItem&gt;
				&lt;asp:ListItem Value=&quot;10/31/2004&quot;&gt;10/31/2004&lt;/asp:ListItem&gt;
				&lt;asp:ListItem Value=&quot;11/30/2004&quot;&gt;11/30/2004&lt;/asp:ListItem&gt;
				&lt;asp:ListItem Value=&quot;12/31/2004&quot;&gt;12/31/2004&lt;/asp:ListItem&gt;
			&lt;/asp:dropdownlist&gt;&lt;asp:button id=&quot;BtnExport&quot; style=&quot;Z-INDEX: 106; LEFT: 176px; POSITION: absolute; TOP: 168px&quot;
				runat=&quot;server&quot; Width=&quot;192px&quot; Height=&quot;48px&quot; Text=&quot;Export to Excel&quot; ToolTip=&quot;Export My Clients to Excel&quot; CausesValidation=&quot;False&quot;&gt;&lt;/asp:button&gt;&lt;asp:hyperlink id=&quot;HypHome&quot; style=&quot;Z-INDEX: 110; LEFT: 16px; POSITION: absolute; TOP: 128px&quot; runat=&quot;server&quot;
				ForeColor=&quot;Navy&quot; NavigateUrl=&quot;Broadcast.aspx&quot; Target=&quot;_parent&quot;&gt;Home&lt;/asp:hyperlink&gt;&lt;asp:textbox id=&quot;TextBox1&quot; style=&quot;Z-INDEX: 112; LEFT: 8px; POSITION: absolute; TOP: 48px&quot; runat=&quot;server&quot;
				Visible=&quot;False&quot;&gt;&lt;/asp:textbox&gt;
			&lt;DIV style=&quot;Z-INDEX: 113; LEFT: 2px; OVERFLOW: auto; WIDTH: 996px; POSITION: relative; TOP: 384px; HEIGHT: 478px&quot;&gt;&lt;asp:datagrid id=Dg runat=&quot;server&quot; Width=&quot;978px&quot; Height=&quot;200px&quot; BorderColor=&quot;#99CC00&quot; BorderStyle=&quot;Solid&quot; DataKeyField=&quot;MstClientID&quot; AutoGenerateColumns=&quot;False&quot; BorderWidth=&quot;3px&quot; ShowHeader=&quot;False&quot; DataSource=&quot;&lt;%# DsLoadClients %&gt;&quot; AllowSorting=&quot;True&quot;&gt;
					&lt;HeaderStyle ForeColor=&quot;White&quot; BackColor=&quot;Navy&quot;&gt;&lt;/HeaderStyle&gt;
					&lt;Columns&gt;
						&lt;asp:TemplateColumn SortExpression=&quot;MstClientID&quot; HeaderText=&quot;Cli Id&quot;&gt;
							&lt;ItemStyle Width=&quot;50px&quot;&gt;&lt;/ItemStyle&gt;
							&lt;ItemTemplate&gt;
								&lt;asp:HyperLink id=HypCliId runat=&quot;server&quot; Text='&lt;%# DataBinder.Eval(Container, &quot;DataItem.MstClientID&quot;) %&gt;' NavigateUrl='&lt;%#&quot;ReconMthly.aspx?ID=&quot; + DataBinder.Eval(Container, &quot;DataItem.MstClientID&quot;)%&gt;'&gt;
								&lt;/asp:HyperLink&gt;
							&lt;/ItemTemplate&gt;
						&lt;/asp:TemplateColumn&gt;
						&lt;asp:TemplateColumn SortExpression=&quot;MstNameonRpt&quot; HeaderText=&quot;Client Name&quot;&gt;
							&lt;ItemStyle Width=&quot;175px&quot;&gt;&lt;/ItemStyle&gt;
							&lt;ItemTemplate&gt;
								&lt;asp:HyperLink id=HypCName runat=&quot;server&quot; NavigateUrl='&lt;%# &quot;ReconMthly.aspx?CName=&quot; + DataBinder.Eval(Container, &quot;DataItem.MstNameonRpt&quot;) + &quot;&amp;Id=&quot; + DataBinder.Eval(Container, &quot;DataItem.MstClientId&quot;) %&gt; ' Text='&lt;%# DataBinder.Eval(Container, &quot;DataItem.MstNameonRpt&quot;) %&gt;'&gt;
								&lt;/asp:HyperLink&gt;
							&lt;/ItemTemplate&gt;
						&lt;/asp:TemplateColumn&gt;
						&lt;asp:TemplateColumn SortExpression=&quot;MstDTIARep&quot; HeaderText=&quot;Advisor&quot;&gt;
							&lt;ItemStyle Width=&quot;100px&quot;&gt;&lt;/ItemStyle&gt;
							&lt;ItemTemplate&gt;
								&lt;asp:HyperLink id=HypAdvisor runat=&quot;server&quot; Text='&lt;%# DataBinder.Eval(Container, &quot;DataItem.MstDTIARep&quot;) %&gt;'&gt;
								&lt;/asp:HyperLink&gt;
							&lt;/ItemTemplate&gt;
						&lt;/asp:TemplateColumn&gt;
						&lt;asp:TemplateColumn SortExpression=&quot;MstDTIAProxy&quot; HeaderText=&quot;Contact&quot;&gt;
							&lt;ItemTemplate&gt;
								&lt;asp:HyperLink id=HypContact runat=&quot;server&quot; Text='&lt;%# DataBinder.Eval(Container, &quot;DataItem.MstDTIAProxy&quot;) %&gt;'&gt;
								&lt;/asp:HyperLink&gt;
							&lt;/ItemTemplate&gt;
						&lt;/asp:TemplateColumn&gt;
						&lt;asp:BoundColumn DataField=&quot;MoReconStatus&quot; SortExpression=&quot;MoReconStatus&quot; HeaderText=&quot;Status&quot; ItemStyle-Width=&quot;100px&quot;&gt;&lt;/asp:BoundColumn&gt;
						&lt;asp:TemplateColumn SortExpression=&quot;InternalDueDate&quot; HeaderText=&quot;Due Date&quot; ItemStyle-Width=&quot;75px&quot;&gt;
							&lt;ItemTemplate&gt;
								&lt;asp:TextBox id=txtDueDate runat=&quot;server&quot; Width=&quot;90px&quot; Text='&lt;%# DataBinder.Eval(Container, &quot;DataItem.InternalDueDate&quot;, &quot;{0:d}&quot;) %&gt;'&gt;
								&lt;/asp:TextBox&gt;
							&lt;/ItemTemplate&gt;
						&lt;/asp:TemplateColumn&gt;
						&lt;asp:TemplateColumn SortExpression=&quot;RptPriority&quot; HeaderText=&quot;Priority&quot; ItemStyle-Width=&quot;50px&quot;&gt;
							&lt;ItemTemplate&gt;
								&lt;asp:TextBox id=txtRptPriority runat=&quot;server&quot; Width=&quot;58px&quot; Text='&lt;%# DataBinder.Eval(Container, &quot;DataItem.RptPriority&quot;) %&gt;'&gt;
								&lt;/asp:TextBox&gt;
							&lt;/ItemTemplate&gt;
						&lt;/asp:TemplateColumn&gt;
						&lt;asp:TemplateColumn SortExpression=&quot;RptType&quot; HeaderText=&quot;Report Type&quot;&gt;
							&lt;ItemTemplate&gt;
								&lt;asp:HyperLink id=HypRptType runat=&quot;server&quot; Text='&lt;%# DataBinder.Eval(Container, &quot;DataItem.RptType&quot;) %&gt;'&gt;
								&lt;/asp:HyperLink&gt;
							&lt;/ItemTemplate&gt;
						&lt;/asp:TemplateColumn&gt;
						&lt;asp:TemplateColumn SortExpression=&quot;ReviewComplete&quot; HeaderText=&quot;Sent To Review&quot;&gt;
							&lt;ItemStyle Width=&quot;100px&quot;&gt;&lt;/ItemStyle&gt;
							&lt;ItemTemplate&gt;
								&lt;asp:HyperLink id=HypSentTo runat=&quot;server&quot; Text='&lt;%# DataBinder.Eval(Container, &quot;DataItem.DateSenttoReview&quot;,  &quot;{0:MM-dd-yyy}&quot;)%&gt;'&gt;
								&lt;/asp:HyperLink&gt;
							&lt;/ItemTemplate&gt;
						&lt;/asp:TemplateColumn&gt;
						&lt;asp:BoundColumn DataField=&quot;DateReportOut&quot; SortExpression=&quot;DateReportOut&quot; HeaderText=&quot;Report Sent&quot;
							DataFormatString=&quot;{0:MM-dd-yyy}&quot;&gt;
							&lt;ItemStyle Width=&quot;100px&quot;&gt;&lt;/ItemStyle&gt;
						&lt;/asp:BoundColumn&gt;
					&lt;/Columns&gt;
				&lt;/asp:datagrid&gt;&lt;/DIV&gt;
			&lt;asp:table id=&quot;HeaderTable&quot; style=&quot;Z-INDEX: 114; LEFT: 16px; POSITION: absolute; TOP: 336px&quot;
				Width=&quot;978px&quot; Height=&quot;25px&quot; BorderColor=&quot;#99CC00&quot; BorderStyle=&quot;Solid&quot; BackColor=&quot;navy&quot;
				ForeColor=&quot;White&quot; BorderWidth=&quot;2px&quot; CellSpacing=&quot;1&quot; Runat=&quot;server&quot; CellPadding=&quot;1&quot; GridLines=&quot;Vertical&quot;&gt;
				&lt;asp:TableRow ForeColor=&quot;White&quot;&gt;
					&lt;asp:TableCell Width=&quot;75px&quot; Text=&quot;Check1&quot; ID=&quot;Cell1&quot;&gt;&lt;/asp:TableCell&gt;
					&lt;asp:TableCell Width=&quot;250px&quot; Text=&quot;Check1&quot; ID=&quot;Tablecell1&quot;&gt;&lt;/asp:TableCell&gt;
					&lt;asp:TableCell Width=&quot;125px&quot; Text=&quot;Check1&quot; ID=&quot;Tablecell2&quot;&gt;&lt;/asp:TableCell&gt;
					&lt;asp:TableCell Width=&quot;150px&quot; Text=&quot;Check1&quot; ID=&quot;Tablecell3&quot;&gt;&lt;/asp:TableCell&gt;
					&lt;asp:TableCell Width=&quot;125px&quot; Text=&quot;Check1&quot; ID=&quot;Tablecell4&quot;&gt;&lt;/asp:TableCell&gt;
					&lt;asp:TableCell Width=&quot;145px&quot; Text=&quot;Check1&quot; ID=&quot;Tablecell5&quot;&gt;&lt;/asp:TableCell&gt;
					&lt;asp:TableCell Width=&quot;70px&quot; Text=&quot;Check1&quot; ID=&quot;Tablecell6&quot;&gt;&lt;/asp:TableCell&gt;
					&lt;asp:TableCell Width=&quot;70px&quot; Text=&quot;Check1&quot; ID=&quot;Tablecell7&quot;&gt;&lt;/asp:TableCell&gt;
					&lt;asp:TableCell Width=&quot;150px&quot; Text=&quot;Check1&quot; ID=&quot;Tablecell8&quot;&gt;&lt;/asp:TableCell&gt;
					&lt;asp:TableCell Width=&quot;140px&quot; Text=&quot;Check1&quot; ID=&quot;Tablecell9&quot;&gt;&lt;/asp:TableCell&gt;
				&lt;/asp:TableRow&gt;
			&lt;/asp:table&gt;&lt;asp:label id=&quot;lblLocation&quot; style=&quot;Z-INDEX: 115; LEFT: 88px; POSITION: absolute; TOP: 128px&quot;
				runat=&quot;server&quot; Width=&quot;72px&quot; ForeColor=&quot;Navy&quot;&gt;MyClients&lt;/asp:label&gt;&lt;asp:textbox id=&quot;TxtCount&quot; style=&quot;Z-INDEX: 116; LEFT: 272px; POSITION: absolute; TOP: 888px&quot;
				runat=&quot;server&quot; Width=&quot;48px&quot;&gt;&lt;/asp:textbox&gt;&lt;asp:label id=&quot;Label2&quot; style=&quot;Z-INDEX: 117; LEFT: 16px; POSITION: absolute; TOP: 888px&quot; runat=&quot;server&quot;
				Width=&quot;248px&quot; Height=&quot;18px&quot; BorderColor=&quot;#99CC00&quot; BorderStyle=&quot;Solid&quot; BackColor=&quot;Navy&quot; ForeColor=&quot;White&quot; BorderWidth=&quot;2px&quot;&gt;Total Number of Clients (per Mth End)&lt;/asp:label&gt;
		&lt;/form&gt;
	&lt;/body&gt;
&lt;/HTML&gt;
 
OK as far as I can see there is nothing wrong with the HTML side of things. Could you explain what "dgPrint" is as it's not referenced in your HTML (I'm assuming it is a datagrid) and why you are calling the RenderControl method for it?

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
The DgPrint is the Datagrid created under the export button for the rendering.. I recreate the datagrid under both print and export....
I think I might know what's going on, but if you see something let me know....

THANKS
Here is the print code:

Code:
        ReBindData() 'my function that binds the datagrind with the data


        Dim strFileName As String = "MyClients.xls"
        Response.AddHeader("Content-Disposition", "attachment; filename=""" & strFileName & """")

        Response.Clear()
        Response.Buffer = True
        Response.Charset = " "
        Response.ContentType = "application/vnd.ms-excel"
        Dim stringWrite As New System.IO.StringWriter
        Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)
        Dim DgPrint As New DataGrid
        DgPrint = Me.Dg

        DgPrint.GridLines = GridLines.Both
        DgPrint.HeaderStyle.Font.Bold = True
        DgPrint.RenderControl(htmlWrite)
        Response.Write(stringWrite.ToString)
        Response.End()
 
i think you're Response.Write(stringWrite.ToString) is writing the text at the beginning or the end of the page outside the Form Tags. Try put a placeholder on the screen and adding the datagrid to the placeholder controls collection
 
I fixed the issue... I actually just cleared the controls, because I've been reading and it states that you need to make sure they are literal controls, not textboxes...
So here is my code for the update version..

Code:
Sub ClearControls(ByVal control As Control)
        Dim i As Integer
        For i = control.Controls.Count - 1 To 0 Step -1
            ClearControls(control.Controls(i))
        Next i

        If TypeOf control Is System.Web.UI.WebControls.Image Then
            control.Parent.Controls.Remove(control)
        End If

        If (Not TypeOf control Is TableCell) Then
            If Not (control.GetType().GetProperty("SelectedItem") Is Nothing) Then
                Dim literal As New LiteralControl
                control.Parent.Controls.Add(literal)
                Try
                    literal.Text = CStr(control.GetType().GetProperty("SelectedItem").GetValue(control, Nothing))
                Catch
                End Try
                control.Parent.Controls.Remove(control)
            Else
                If Not (control.GetType().GetProperty("Text") Is Nothing) Then
                    Dim literal As New LiteralControl
                    control.Parent.Controls.Add(literal)
                    literal.Text = CStr(control.GetType().GetProperty("Text").GetValue(control, Nothing))
                    control.Parent.Controls.Remove(control)
                End If
            End If
        End If
        Return
    End Sub

THANKS FOR ALL THE HELP..!!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top