Archive for the ‘Compiler Errors And Messages’ Category

BC30456: ‘javascript’ is not a member of ‘ASP.pickdate_aspx’.

Transfer the calling function from OnClick to OnClientClick event of the control.

, ,

No Comments


Export Datagrid Data to Excel error ‘DataGridLinkButton’ must be placed inside a form tag with runat=server.

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.

  1.  
  2.     Public Sub ClearControls(ByVal control As Control)
  3.         'This function is used to Clear all the controls in the datagrid
  4.         'Will Clear all the ServerControls Which are in the Datagrid
  5.         'Such as edit command, paging, checkboxes in datagrid and all
  6.         'the server controls
  7.         'it will replace the server control with simple text for that control
  8.         'Where Can this be Used:
  9.         'Exporting Datagrid and Clearing Datagrid
  10.         Dim i As Integer
  11.         For i = control.Controls.Count - 1 To 0 Step -1
  12.             ClearControls(control.Controls(i))
  13.         Next i
  14.  
  15.         If Not TypeOf control Is System.Web.UI.WebControls.TableCell Then
  16.             If Not (control.GetType().GetProperty("SelectedItem") Is Nothing) Then
  17.                 Dim literal As New LiteralControl
  18.                 control.Parent.Controls.Add(literal)
  19.                 Try
  20.                     literal.Text = CStr(control.GetType().GetProperty("SelectedItem").GetValue(control, Nothing))
  21.                 Catch
  22.                 End Try
  23.                 control.Parent.Controls.Remove(control)
  24.             Else
  25.                 If Not (control.GetType().GetProperty("Text") Is Nothing) Then
  26.                     Dim literal As New LiteralControl
  27.                     control.Parent.Controls.Add(literal)
  28.                     literal.Text = CStr(control.GetType().GetProperty("Text").GetValue(control, Nothing))
  29.                     control.Parent.Controls.Remove(control)
  30.                 End If
  31.             End If
  32.         End If
  33.         Return
  34.     End Sub 'ClearControls
  35.  
  36.     Protected Sub btnDownload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDownload.Click
  37.         Response.Clear()
  38.         Dim filename As String = "filename_" & Strings.Format(DateTime.Today, "MM-dd-yyyy") & ".xls"
  39.  
  40.         Response.Clear()
  41.         Response.AddHeader("content-disposition", "attachment; filename=" & filename)
  42.         Response.Charset = ""
  43.         Response.ContentType = "application/vnd.xls"
  44.         Me.EnableViewState = False
  45.         Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter()
  46.         Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
  47.         Response.Buffer = False
  48.         ClearControls(DataGrid1)
  49.         Me.DataGrid1.RenderControl(htmlWrite)
  50.         Response.Write(stringWrite.ToString())
  51.         'stringWrite.Dispose()
  52.         'htmlWrite.Dispose()
  53.  
  54.         Response.End()
  55.  
  56.         'Download()
  57.  
  58.     End Sub

, , ,

No Comments


cannot have multiple items selected in a dropdownlist

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();

, ,

No Comments


BC30456: ‘InitializeCulture’ is not a member of

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

,

No Comments


InvalidOperationException : There was an error in XML document

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, “”)

No Comments


syntax not valid in a Namespace

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.

,

No Comments


Debugging Problem

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.

,

No Comments



SetPageWidth