none
Problems using ASP.NET tools in Expresion Web 4 RRS feed

  • Question

  • I have recently install Expression Web 4 and when I drag a ASP.NET Controls (Button) I get an error "Error Creating Contol - Button1 Object reference not set to an instance of an object.  I have downloaded .net 4 Framework as well as Web Platform Installer and still no luck.  Adding the button was the first thing I did when I started my first project.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Untitled 1</title>
    </head>
    
    <body>
    
    <form id="form1" runat="server">
    	<asp:Button id="Button1" runat="server" Text="Button" />
    </form>
    
    </body>
    
    </html>
    

    Friday, May 24, 2019 2:34 PM

Answers

  • well that might be a problem.  I do not have New Site as an option.  I'll have to figure that one out and get back to you.

    • Marked as answer by wgraulich Tuesday, May 28, 2019 4:36 PM
    Tuesday, May 28, 2019 3:38 PM

All replies

  • Web Platform Installer has nothing to do with EW.

    When do you see the error?

    Did you create a new site in EW on your local PC, then create a new .aspx page in that site?  Your markup doesn't have a page declaration at the top, which means you didn't create is as an .aspx file in EW.

    <%@ Page Language="C#" %>

    Do you have a web.config file in the site?  (File -> New -> Page, select Asp.Net, then Web configuration 4.0)?

    (You'll need to manually up the version from 4.0 to 4.5 or whatever you want to use in the web.config file.)


    Kathleen Wilber
    BrightWillow - Asp.Net Applications

    Friday, May 24, 2019 4:30 PM
  • This is my web.config 

    <?xml version="1.0" encoding="utf-8"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      https://go.microsoft.com/fwlink/?LinkId=169433
      -->
    <configuration>
      <connectionStrings>
        <add name="test" connectionString="Data Source=CADSQL;Initial Catalog=System;Integrated Security=True"
          providerName="System.Data.SqlClient" />
        <add name="CADSQL" connectionString="Data Source=CADSQL;Initial Catalog=System;User ID=sa;Password=tr1t3ch"
          providerName="System.Data.SqlClient" />
      </connectionStrings>
      <system.web>
        <compilation debug="true" strict="false" explicit="true" targetFramework="4.7.2"/>
        <httpRuntime targetFramework="4.7.2"/>
        <pages>
          <namespaces>
            <add namespace="System.Web.Optimization"/>
          </namespaces>
          <controls>
            <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt"/>
          </controls>
        </pages>
      </system.web>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f"/>
            <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2"/>
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed"/>
            <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0"/>
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35"/>
            <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930"/>
          </dependentAssembly>  
        </assemblyBinding>
      </runtime>
      <system.codedom>
        <compilers>
          <compiler language="c#;cs;csharp" extension=".cs"
            type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701"/>
          <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
            type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
        </compilers>
      </system.codedom>
    </configuration>

    This is my revised code for the page and it still does not work.

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="cad_id_numbers.aspx.vb" Inherits="OnCallWeb.cad_id_numbers" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <style type="text/css">
            .auto-style1 {
                font-size: x-large;
            }
        a:visited {
    	color: #0000FF;
    }
    a:active {
    	color: #0000FF;
    }
    a:hover {
    	color: #FF00FF;
    }
        </style>
    </head>
    <body style="text-align: center">
        <form id="form1" runat="server">
            <div>
            <div style="font-weight: 700; font-style: italic; font-size: 36pt">
                Union County On Call Website</div>
            </div>
            <p style="font-style: italic; color: #0000FF" class="auto-style1">
                On Call Page&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    			<a href="../Home_Page.aspx">Home Page </a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Policy &amp; Procedure Page</p>
            <p style="font-size: xx-large; font-weight: 700; font-style: italic; color: #0000FF">
                CAD ID Numbers</p>
            <p style="font-size: xx-large; font-weight: 700; font-style: italic; color: #0000FF">
                <asp:Button ID="Button2" runat="server" style="font-size: large" Text="Clear Search" Width="130px" />
            </p>
            <p style="font-size: x-large; color: #000000">
                Enter Employee Name Here
                <asp:TextBox ID="TextBox1" runat="server" style="font-size: x-large" Width="340px"></asp:TextBox>
    &nbsp;
                <asp:Button ID="Button1" runat="server" style="font-size: large" Text="Search" Width="85px" />
            </p>
              <center>
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataSourceID="CADSQL" GridLines="Vertical" style="text-align: center; font-size: x-large">
                    <AlternatingRowStyle BackColor="#DCDCDC" />
                    <Columns>
                        <asp:BoundField DataField="Emp_Name" HeaderText="Employee Name" SortExpression="Emp_Name" />
                        <asp:BoundField DataField="Emp_ID" HeaderText="CAD ID Number" SortExpression="Emp_ID" />
                    </Columns>
                    <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
                    <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
                    <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
                    <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
                    <SortedAscendingCellStyle BackColor="#F1F1F1" />
                    <SortedAscendingHeaderStyle BackColor="#0000A9" />
                    <SortedDescendingCellStyle BackColor="#CAC9C9" />
                    <SortedDescendingHeaderStyle BackColor="#000065" />
                </asp:GridView>
              <center>
                <asp:SqlDataSource ID="CADSQL" runat="server" ConnectionString="<%$ ConnectionStrings:CADSQL %>" SelectCommand="SELECT [Emp_Name], [Emp_ID] FROM [Personnel] WHERE ([Emp_Name] LIKE '%' + @Emp_Name + '%')">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="TextBox1" Name="Emp_Name" PropertyName="Text" Type="String" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </p>
        </form>
    </body>
    </html>
    

    Friday, May 24, 2019 5:06 PM
  • When do you see the error, and what is the exact error? Your second post is far from "add a button to the page".

    How did you create that web.config?  It is not one EW would create.

    Since I don't have your database, your post is not something I can run and debug, other than to say there is no error for the page itself inside EW, other than pointing out in code view that <center> isn't valid in HTML5 and that you have an extra </p> before the final </form> tag.


    Kathleen Wilber
    BrightWillow - Asp.Net Applications

    Saturday, May 25, 2019 1:47 AM
  • The web.config was created when I created a new project in Visual Studio 2019 using ASP.NET Applications (.Net Framework) in C#.

    In regards to the error it is appearson the page as soon as I drag and drop a button onto my page "Error Creating Control - Button 1 Object reference not set to an instance of an object."  I would love to share the project but I don't know how I can do that.

    Saturday, May 25, 2019 2:40 PM
  • If you started the project in Visual Studio, why are you not using Visual Studio for it?

    Regardless, there is really nothing I can do from here, since I have no idea if you are opening a website that EW understands is a website, with the root at the level you opened it in EW, and the web.config in that root.

    If you are, I have no further ideas.  That error tells me nothing about why EW doesn't think you are dealing with an asp.net site/page.

    The obvious thing to do is work on it in Visual Studio and see if you have the same problem.


    Kathleen Wilber
    BrightWillow - Asp.Net Applications

    Sunday, May 26, 2019 5:02 AM
  • So to make it easier I created a new website and just using EW and I still get the same error.  This is my file structure and it still does not work.
    Tuesday, May 28, 2019 11:52 AM
  • Create a new empty website on your C drive using EW4. Site -> New Site -> Empty Site

    Create a web.config for it using EW4, using File => New => Asp.Net => web.config 4.

    Edit the web.config and change 4 to 4.7.

    Create a new page using EW4: File => New -> ASPX and save it.

    Drag an asp.net button control into the form area.

    Does this work?


    Kathleen Wilber
    BrightWillow - Asp.Net Applications

    Tuesday, May 28, 2019 2:53 PM
  • well that might be a problem.  I do not have New Site as an option.  I'll have to figure that one out and get back to you.

    • Marked as answer by wgraulich Tuesday, May 28, 2019 4:36 PM
    Tuesday, May 28, 2019 3:38 PM
  • That did it.  Thanks for your help and fast replies.

    Tuesday, May 28, 2019 4:37 PM