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.

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 = "";
                    }
                }
            }
        }

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>"

 

 

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>

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>

Tags:

ASP.NET

Powered by BlogEngine.NET 1.6.0.0
Theme by Mads Kristensen