Neudesic Blogs

Think Smart. Get Results.
Welcome to Neudesic Blogs Sign in | Join | Help
in Search

Pete Orologas

  • Extending .NET AjaxControlToolkit Autocomplete Control for Facebook Style Search

     

    Problem: Give data-entry folks the ability to search through high schools in a quick and efficient manner.  The user should be able to search by high school name, city or zip and it should not to affect the user's productivity. Note: This is in a web-based environment.

     

    Solution: Extend the existing AjaxControlToolkit autocomplete control to provide similar functionality to the Facebook’s search control.  See screen shots below.


    Sample Solution and Source Code

    Search By Name:

     

    Search by Zip:

     

    Search By City:

    Add Watermark:

     

    The solution fits all our clients’ criteria.

     

    Fast:  The control is fast for a number of reasons. First off we are not rendering all the high schools on the client side.  Instead we are using Ajax calls to retrieve the list of high schools from a web-service.  Since the high school information in our database doesn't change very often we cache the results with an expiration (2 days) saving us time and saving the database effort.  Another reason the control performs very well is the fact that we only search when a user has typed 3 or more characters and we only return X number of results instead of every matching result.  If the user needs to further filter the results they simply add on another letter (or number depending on their search).

     

    Productive: The autocomplete control is especially efficient for data-entry. Unlike a listbox or dropdown the user does not have to use the mouse to make a selection.  The user simply tabs into the textbox and begins typing.  This is not to say that a drop-down and a listbox don't have their own benefits but it's important to use the right control for the right purpose.  A listbox and a text box wouldn't be efficient because of the size of our dataset

     

    Multiple Search Criteria:  Above we covered some limitations of dropdowns and listboxes but the main drawback for our requirements was the lack of multiple search criteria.  The autocomplete control gives us the ability to customize our searches anyway we see fit.

     

     

    Please post comments and ideas.


    Sample Solution and Source Code
    *Please note that FireFox was not supported with this solution.

     

    Pete Orologas

     

  • Retrieve ClickOnce Published Build Number

    Want to create an "About" form for your ClickOnce application?  Here is how you can retrieve the current build number. 

    NOTE: The CurrentDeployment static property is valid only from within an application that was deployed using ClickOnce. Attempts to call this property from non-ClickOnce applications will throw an exception. In debug mode the IsNetworkDeployed property will always be false.

    if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)

    {

    System.Deployment.Application.ApplicationDeployment applicationDeployment = System.Deployment.Application.ApplicationDeployment.CurrentDeployment;

    Version version = applicationDeployment.CurrentVersion;

    LABEL.Text = string.Format("Published Version: v{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision);

    }

    Give me a shout if this helped you out.

    Pete Orologas

  • Missing Sql Server Management Studio - solution

    The other day I was installing SQL Server 2005 and realized that the installation did not install Management Studio.  So I reinstalled the sql tools from the CD but that didn't work so I uninstalled and reinstalled, still no luck.  The only item which would show up under start-> programs-> Microsoft SQL Server is the Configuration Tools.   If you are having the same issue you've come to the right place.

    Problem: 

          SQL Server Management Studio did not install with sql server 2005

    Issue:

           When installing visual studio you may have installed SQLExpress, which created a tools folder in "C:\Program Files\Microsoft SQL Server\90".  SQL Server installation will look for that folder and if it's found it will simply move on.

    Solution:            Rename the tools folder in C:\Program Files\Microsoft SQL Server\90 and then reinstall the tools and components off the CD. 

    This solution seems to be working for most people.  Give Props to Koti for solving the problem.

    KOTI: Recommends re-installing tools by gonig to set-up files and double clicking "SqlRun_Tools" exe file, then selected necessary tool to be installed. which worked like gem.

    Hope this helps someone out.

    Pete Orologas

  • Visual Studio Database Professionals - Data Generation

    Visual Studio Database Professional (VSDBP)- Data Generation.

    Our DBA came by the other day to let us know our database was complete.  We were pleased to begin coding against it only to find that it had no data.  Although we neglected to add data we did not neglect to turn on referential integrity, which means it's a pain in the *** to populate.  The dilemma we now faced was how to generate data so we can begin working.  Enter VSDBP and it's data generation capability.  You can see in the image below what the generated data looks like (bottom left). The column "CollegeName" uses a regular expression to limit the generated data so that we do not generate a 'Y' with a tilda above it (look at LastUpdatedBy).  I just wanted to say that VSDBP isn't released yet but its already shown it's worth to me and my team.

    Visual Studio Database Professionals is currently in CTP1 which basically means it will crash on you...constantly. All that aside however it's going to be a sweet tool whether you're a DB or not you'll have to learn it. (yes I know it's a preposition)

     

    Pete Orologas

    Download VSDBP

     

  • Firefox - Enter username and password for "" at http://localhost - Solution

    IIS uses Integrated Authentication and by default IE has the ability to use your windows user account...but don't worry, so does Firefox but you'll have to make a quick configuration change.

    1) Open up Firefox and type in about:config as the url

    2) In the Filter Type in ntlm

    3) Double click "network.automatic-ntlm-auth.trusted-uris" and type in localhost and hit enter

    4) Write Thank You To Blogger

    As Always, Hope this helped you out.

    Pete Orologas

     

  • HTTP 401.1 - Unauthorized: Logon Failed -- Integrated Authentication

    If you are running into a weird integrated security authentication behavior... this is your fix.

     

    This will fix your HTTP 401.1 - Unauthorized: Logon Failed issue for Reporting Services or CRM.

     

    This issue occurs if you install Microsoft Windows XP Service Pack 2 (SP2) or Microsoft Windows Server 2003 Service Pack 1 (SP1).Windows XP SP2 and Windows Server 2003 SP1 include a loopback check security feature that is designed to help prevent reflection attacks on your computer. Therefore, authentication fails if the FQDN or the custom host header that you use does not match the local computer name.

     

    1.

    Click Start, click Run, type regedit, and then click OK.

    2.

    In Registry Editor, locate and then click the following registry key:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa

    3.

    Right-click Lsa, point to New, and then click DWORD Value.

    4.

    Type DisableLoopbackCheck, and then press ENTER.

    5.

    Right-click DisableLoopbackCheck, and then click Modify.

    6.

    In the Value data box, type 1, and then click OK.

    7.

    Quit Registry Editor, and then restart your computer.

    http://support.microsoft.com/default.aspx?scid=kb;en-us;896861

    As Always Give a shout out if this helped you fiix your issue.

    Pete Orologas

     

     

  • How to Sort a ListBox

    Don't forget to give me a shout out if this helped you!! .... shout out = nice comment :)

     

    *****    Helper Method for Sorting ListBoxes     *********

     

    private void SortListbox(ListBox box)
    {
        SortedList sortedItems = new SortedList();

        for(int i = 0; box.Items.Count - i != 0; i++)
        {
            sortedItems.Add(box.Items[i].Text, box.Items[i].Value);
        }

        if (sortedItems.Count != 0)
        {
            box.Items.Clear();
            box.DataSource = sortedItems;
            box.DataTextField = "key";
            box.DataValueField = "value";
            box.DataBind();
        }
    }

    Pete Orologas

  • Web Part Error - (SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

    I apologize for the formatting... we're in the process of upgrading our blog server

    The Issue:

       The webpartmanager is looking for SQL Express 2005 which, by default, is the personalization provider.  We can work around this but if you are really eager to see your page displayed you can set the Personalization-Enabled="false" in the webpartmanager.  This will render your page but it will also defeat any purpose of using webparts.  For the real solution read on.

    The Solution: (3 simple steps)

    1) Open your visual studio command prompt located in "Start Menu\Programs\Microsoft Visual Studio 2005\Visual Studio Tools\Visual Stuido 2005 Command Prompt" and type in aspnet_regsql.exe.  This will launch a wizard so that you can either create a DB or add tables to an existing database for storing personalization infromation. Click Next, Next, then enter in your DBServer Name. Lets leave the DB as "default" for now, click next, next, finish.  By leaving the db as default the tool will create a database named aspnetdb

    2) Now we have a database so we will need a connection string to access it from our  Personalization Provider in Step 3.  The connection string will go into your web.config and it will be similar to the one show below:

    <connectionStrings>

      <remove name="LocalSqlServer" />

     <add name="DBConn" connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=aspnetdb;Data Source=DBServer" providerName="System.Data.SqlClient" />

    </connectionStrings>

     

    Note: The "remove" tag is used to inform Visual Studio that we will not be using SQL Express

    3) The final step is to add our own personalization provider in the <system.web> section of the webConfig.  The personalization provider will point to the store we created by using the connection string we provide (Dbconn).

    <webParts>

        <personalization  defaultProvider="AspNetSqlPersonalizationProvider">

            <providers>

                 <remove name="AspNetSqlPersonalizationProvider" />

                 <add name="AspNetSqlPersonalizationProvider"

                 type="System.Web.UI.WebControls.WebParts.SqlPersonalizationProvider"

                 connectionStringName="DBConn"

                 applicationName="/" />

            </providers>

        </personalization>

    </webParts>

     

    ALL DONE !!!  Congrats you should be up and running.

    Give me shout-out if this helped you !!

    Pete Orologas

  • Menu Control Horizontal Layout - Asp.net 2.0

    The Menu Control has to be one of the coolest and most frustrating controls I've worked with.  Anyways, if you're here to figure out how to make your control horizontal, you've come to the right place.

     

    To begin set your SiteMapDataSource as shown below:

    <asp:SiteMapDataSource ID="SiteMapDataSource2" runat="server" ShowStartingNode="false" StartingNodeOffset="0" /> 

     

    <asp:Menu ID="Menu1" StaticDisplayLevels="2"  runat="server" Orientation="Horizontal" DataSourceID="SiteMapDataSource2"></asp:Menu>

    Thats it!!! ( NOTE: The trick is the StaticDisplayLevel setting not the orientation) 

    Here is the Web.Sitemap: everything in red is what will display in your menu

    (IT should look like this)

    Root     A     B    C

    <?xml version="1.0" encoding="utf-8" ?>
    <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
      <siteMapNode>
       
          <siteMapNode url="Default.aspx" title="Root"  description="" roles="">
            <siteMapNode url="A.aspx" title="A"  description="" roles="">
              <siteMapNode url="1.aspx" title="1"  description="" roles="" />
              <siteMapNode url="2.aspx" title="2"  description="" roles="" />
            </siteMapNode>
            <siteMapNode url="B.aspx" title="B"  description="" roles="">
              <siteMapNode url="3.aspx" title="3"  description="" roles="" />
              <siteMapNode url="4.aspx" title="4"  description="" roles="" />
            </siteMapNode>
            <siteMapNode url="C.aspx" title="C"  description="" roles="">
              <siteMapNode url="5.aspx" title="5"  description="" roles="" />
              <siteMapNode url="6.aspx" title="6"  description="" roles="" />
            </siteMapNode>
          </siteMapNode>


      </siteMapNode>
    </siteMap>

    If this helps you, give me a shout out.

    Pete Orologas

     

  • Lost Treasure of Asp.net 2.0

    $ expressions are simple code sequences that can be added to any aspx page as long as they are within a control tag.  The expressions are evaluated by an expression builder and then returned to the control for display.  The builder translates the expression to a string and returns it to the page when it is rendered.  You will find that asp.net includes some built-in expression builders but you can also extend the ExpressionBuilder class to create your own custom expression builders.  Below you will find an example of both Built-In and Custom Expression Builders.

    Built-In

     Three built-in expression builders are the AppSettingsExpressionBuilder, ResourceExpressionBuilder and the ConnectionStringExpressionBuilder. 

     AppSettingsExpressionBuilder:

       Reads from appSettings in web.config

          <asp:Literal runat="server" text="<%$ AppSettings:Key %>" > -- (returns "Neudesic")

          --------------- web config -------------------

          <appSettings>

                   <add key="Key" value="Neudesic"/>

          </appSettings>

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

    ConnectionStringExpressionBuilder:

       Reads from connectionStrings section of web.config.

         <asp:Literal runat="server" text="<%$ ConnectionStrings:DbConn%>" > -- (Returns ConnectionString shown below):

    --------------- web config -------------------

    <connectionStrings>

                <add name="DbConn" connectionString="DataSource=localhost;Integrated Security=SSPI;InitialCatalog=Northwind;" providerName="System.Data.SqlClient" />

    </connectionStrings>

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

    ResourceExpressionBuilder 

    Reads from resource file.    

    Lets say we have a resource file with the following data in a resource file named "ResFileName.resx":

          <data name="Resource">

                <value xml:space="preserve">Hello!</value>

          </data>

       Here is where we make a call using the ResourceExpressionBuilder to retrieve the value "Resource" from our "ResFileName.resx".

          <%$ Resources: ResxFileName, Resource %>  == <% {ExpressionBuilder}: {ResourceFile},{ResourceKey} %>

     

    Custom

    You must register your custom expersion builders so that Asp.Net will know which class to instantiate when your custom expression is encountered.  To register a custom expression builder you will add a <expressionBuilders> section into the <complilation> section of your your web.config

    <!-- From Web.config -->
    <compilation>
      <expressionBuilders>
        <add expressionPrefix="VersionNumber" type="VersionExpressionBuilder"/>
      </expressionBuilders>
    </compilation>

    To display your custom expression builder you simply add it to a control tag.  This is the same method we used with the Built-In expression builders.

    <%@ Page Language="C#" CompileWith="Version.aspx.cs"
      ClassName="Version_aspx" %>
    <html>
      <body>
        <h1>Powered by ASP.NET
          <asp:Literal Text='<%$ Version:MajorMinor %>  or <%$ Version:All %>' Runat="server" />  or
        </h1>
      </body>
    </html>

     

    Code For expression builder. The code is fairly self explanatory.  We inherit from ExpressionBuilder and over ride GetCodeExpression.  The BoundPropertyEntry is the expression after the ":" in our example Version:MajorMinor it's the "MajorMinor".  After we have our EntryExpression we can evaluate it and perform whatever operation we want. 

    public class VersionExpressionBuilder : ExpressionBuilder
    {
        public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
        {
            string param = entry.Expression;

    switch(param)

     {

       case "All":

          Return(new CodePrimitiveExpression (***represent an expression that indicates a primitive data type value***)
                    (String.Format("{0}.{1}.{2}.{3}",
                    Environment.Version.Major,
                    Environment.Version.Minor,
                    Environment.Version.Build,
                    Environment.Version.Revision));

          Break;

          case "MajorMinor":

                   return new CodePrimitiveExpression
                     (String.Format("{0}.{1}",
                     Environment.Version.Major,
                     Environment.Version.Minor));

                   Break;

          default:

                    throw new InvalidOperationException
                    ("Use $ Version:All or $ Version:MajorMinor");

                   Break;

            }
        }
    }

     

    To read more on CustomExpressionBuilder you can visit the "Five Undiscovered Features on ASP.NET 2.0" on MSDN.

    Hope this blog was informative.  All feedback is Welcome.

    Pete Orologas

    Pete.Orologas@Neudesic.com

This Blog

Post Calendar

<July 2008>
SuMoTuWeThFrSa
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

Syndication

Powered by Community Server, by Telligent Systems