Attempted to access an unloaded AppDomain

by Nathan 1. March 2010 07:55
Problem occured when running application in debug mode, have resolved by restarting Visual Studio 2005.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

ASP.NET

Clearing All Textbox Programatically in ASP.NET Web Form

by Nathan 15. July 2009 11:04

There are multiple ways of doing this ie using JavaScript, but this is the server side solution.

You can adapt this method for several other solutions:

        foreach (Control c in this.Page.Controls)
        {                        
            if(c.GetType().FullName.Equals("System.Web.UI.HtmlControls.HtmlForm")) {
                foreach (Control cForm in c.Controls)
                {                        
                    if(cForm.GetType().Equals(typeof(TextBox))) {   
                        ((TextBox)(cForm)).Text = "";
                    }
                }
            }
        }

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

ASP.NET

Selecting Default Values on Dropdown Lists

by Nathan 2. June 2009 10:17

If you would like your application to set the selected item in your dropdownlist to an item from a variable passed to it, or from the database

Here are some examples:

 

ASP.NET 

<asp:DropDownList ID="DropDownList1" runat="server"/><br />

DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByValue(value.ToString()));

 

VBScript ASP Example:

 

  response.write "<select size=""1"" name=""selectData"" id=""selectData"">"
  response.write "<option value='0'>-- Select  Data --</option>"
  do while not objRs.eof

      if (ContactType = objRS("Value")) then
          response.write "<option value='"+cstr(objRS("Value"))+"' selected>"+objRS("Description")+"</option>"
      else
          response.write "<option value='"+cstr(objRS("Value"))+"'>"+objRS("Description")+"</option>"
      end if

      objRs.MoveNext
  loop
  response.write "</select></font></p>"

 

If you have a lot of variables i suggest using a for loop:

 

    response.write "<select name='select1'>"

    Dim MyWebSiteArray
    PrefOddsArray = MyWebSiteArray("web design","design","website","nathan","baker")

    For each Item in MyWebSiteArray

   DatabaseValue = RS("ValueFromDatabase")


   if(DatabaseValue = Item)  then
        response.write "<option value="""+Item+""" selected>"+Item+"</option>\n"
    else
        response.write "<option value="""+Item+""">"+Item+"</option>\n"
    end if
    Next
    response.write "</select></td>"
    response.write "</tr>"

 

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

ASP | ASP.NET

Unable to cast object of type 'System.Web.Configuration.ScriptingAuthenticationServiceSection' to type 'System.Web.Configuration.ScriptingAuthenticationServiceSection'.

by Nathan 29. March 2009 08:42

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: The entry 'ScriptModule' has already been added.

Source Error:

<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>


This happens when the config for a virtual directory is already defined in the root web application

There are two ways you can fix this:

<remove name="ScriptModule" />

Alternatively you can stop the  the web.config inheritance to the the virtual directory.
by adding this to the parent web.config

    <location path="." inheritInChildApplications="false">
    <system.web>
    ...
    </system.web>
    </location>

 

I found out that the root application had .NET 3.5 references in the web.config

I tried to remove this using:

    <location path="." inheritInChildApplications="false">
    <system.web>
    ...
    </system.web>
    </location>


the problem actually occured due to the  3.5 reference in the <configSections>

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

ASP.NET

Inheritance issues in web.config

by Nathan 17. February 2009 17:14

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: The entry 'ScriptModule' has already been added.

Source Error:

<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>


This happens when the config for a virtual directory is already defined in the root web application


There are two ways you can fix this:

<remove name="ScriptModule" />

Alternatively you can stop the  the web.config inheritance to the the virtual directory.
by adding this to the parent web.config

    <location path="." inheritInChildApplications="false">
    <system.web>
    ...
    </system.web>
    </location>


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

I also came upon this problem when trying to fix this issue:

Unable to cast object of type 'System.Web.Configuration.ScriptingAuthenticationServiceSection' to type 'System.Web.Configuration.ScriptingAuthenticationServiceSection'.

which led me to realise there were .NET 3.5 references in the parent application's web.config

I tried to remove this using:

    <location path="." inheritInChildApplications="false">
    <system.web>
    ...
    </system.web>
    </location>

the problem actually occured due to the 3.5 reference in the <configSections>

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

ASP.NET

Unable to serialize the session state

by Nathan 29. January 2009 17:43

Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.

When receiving this error you will need to make your object Serializable.

 ie:

[Serializable]

public class MyClass
{

}

 

Alternatively you can use the InProc Session State.



Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

ASP.NET

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

I am a Website Developer and Designer based in Sydney, Australia. I have experience in developing websites and applications using various languages including C#, VB, C++, Flash (ActionScript), SQL and Linux. You can see some of my projects at www.nathanbaker.com.au

Page List