Archive for the ‘Compiler Errors And Messages’ Category
BC30456: ‘javascript’ is not a member of ‘ASP.pickdate_aspx’.
Posted by: admin in .NET, ASP.Net, Compiler Errors And Messages on March 23rd, 2010
Transfer the calling function from OnClick to OnClientClick event of the control.
asp.net, OnClick, OnClientClick
Export Datagrid Data to Excel error ‘DataGridLinkButton’ must be placed inside a form tag with runat=server.
Posted by: admin in .NET, ASP.Net, Compiler Errors And Messages on March 19th, 2010
I have been browsing on web to find the exact solution. Unfortunately, lots of different suggestions which also not working, and finally I have found an article that’s very interesting.
One reason this error comes up is when the datagrid contains a server control, so you need to verify it before complaining.
There are 2 (maybe more) ways to solve this issue that I have proven and tested.
1. Disable features of the datagrid like sorting and remove unnecessary server controls.
2. If the above solution is not possible because you really need it. So, what you need to do is to clear the server controls on the fly, means you have to implement a sort of mechanism to work, but don’t worry about it there’s already a script that will help you to ease the work.
-
-
Public Sub ClearControls(ByVal control As Control)
-
'This function is used to Clear all the controls in the datagrid
-
'Will Clear all the ServerControls Which are in the Datagrid
-
'Such as edit command, paging, checkboxes in datagrid and all
-
'the server controls
-
'it will replace the server control with simple text for that control
-
'Where Can this be Used:
-
'Exporting Datagrid and Clearing Datagrid
-
Dim i As Integer
-
For i = control.Controls.Count - 1 To 0 Step -1
-
ClearControls(control.Controls(i))
-
Next i
-
-
If Not TypeOf control Is System.Web.UI.WebControls.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 'ClearControls
-
-
Protected Sub btnDownload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDownload.Click
-
Response.Clear()
-
Dim filename As String = "filename_" & Strings.Format(DateTime.Today, "MM-dd-yyyy") & ".xls"
-
-
Response.Clear()
-
Response.AddHeader("content-disposition", "attachment; filename=" & filename)
-
Response.Charset = ""
-
Response.ContentType = "application/vnd.xls"
-
Me.EnableViewState = False
-
Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter()
-
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
-
Response.Buffer = False
-
ClearControls(DataGrid1)
-
Me.DataGrid1.RenderControl(htmlWrite)
-
Response.Write(stringWrite.ToString())
-
'stringWrite.Dispose()
-
'htmlWrite.Dispose()
-
-
Response.End()
-
-
'Download()
-
-
End Sub
'DataGridLinkButton' must be placed inside a form tag with runat=server., asp.net, ClearControl, Export Datagrid to Excel
cannot have multiple items selected in a dropdownlist
Posted by: admin in .NET, ASP.Net, Compiler Errors And Messages on March 3rd, 2010
This error occurs when you set the Selected property of the dropdownlist control and there’s already selected item , example.
dropdownlist.Items.FindByValue(”value”).selected = True
or
dim lst as listitem
lst = dropdownlist.Items.FindByText(”textvalue”)
lst.selected = True
To solve this problem, before you call the above code you need to clear the selection in the dropdownlist.
To clear the selection
dropdownlist.ClearSelection();
BC30456: ‘InitializeCulture’ is not a member of
Posted by: admin in .NET, ASP.Net, Compiler Errors And Messages on January 24th, 2010
1. If you use Visual studio to publish your site, during the publishing stage on framework 2.0 uncheck the “allow this precompiled site to be updatable”.
2. Ensure ASP.Net is installed correctly, I found that my Web Server root was configured to use ASP.Net 1.1 by default so ran the following line to fix it to 2.0 even though my site was configured for 2.0 at site level, eliminating this glitch seems logical.
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -i
This will also fix any mapping/installation problems.
Also ran aspnet_regiis -r
This will replace all mappings recursively to 2.0 regardless.
3. Make sure page directives at the top of aspx files are correct and ‘inherits’ is pointing to your class correctly. I could not see any problems with mine, so did not explore down this path to thoroughly, but noted others saying issues with ambiguous inheritance maybe related.
4. Declare culture in your web.config, example
<globalization uiCulture=”en” culture=”en-NZ” />
OR
<globalization uiCulture=”auto” culture=”auto” />
5. Change debug=”true” to “false” in web.config and any pages which have it set (I recommend removing it entirely from pages and just using web.config)
Source: MSDN Forum
InvalidOperationException : There was an error in XML document
Posted by: admin in .NET, Compiler Errors And Messages, Exception, VB.Net on November 9th, 2009
This error occurred when there is an invalid character on the data. Before adding/saving to the datatable you need to replace the invalid character. The known invalid character is the null.
To replace it in vb.net
dim mData As string
Strings.Replace(mData, vbNullChar, “”)
syntax not valid in a Namespace
Posted by: admin in .NET, Compiler Errors And Messages on May 10th, 2009
The statement cannot appear at the level of a namespace. The only declarations allowed at namespace level are module, interface, class, delegate, enumeration, and structure declarations.
Resolution :
Move the statement to a location within a module, class, interface, structure, enumeration, or delegate definition.
Debugging Problem
Posted by: admin in .NET, C#, Compiler Errors And Messages, VB.Net on April 23rd, 2009
Problem:
The breakpoint will not currently be hit. No symbols have been loaded for this document
Solution:
Make sure that you are compiling in Debug mode not Release mode.