Click here to Skip to main content
15,886,199 members
Articles / Web Development / ASP.NET

ASP.NET C# Search Engine (Highlighting, JSON, jQuery & Silverlight)

Rate me:
Please Sign up or sign in to vote.
4.60/5 (38 votes)
8 Mar 2009CPOL10 min read 376.5K   13.2K   184  
More professional ASP.NET C# search with proper document summary, query highlighting and RIA display options
<UserControl x:Class="Silverlightaroo.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="600" Height="500">
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="28"></RowDefinition>
            <RowDefinition Height="28"></RowDefinition>
            <RowDefinition Height="28"></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <TextBlock Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" 
            Text="Silverlight-aroo (Searcharoo + JSON)" Foreground="Orange" Padding="6"/>
        <TextBox Grid.Column="0" Grid.Row="1" x:Name="query" Text="dollar" />
        <Button Grid.Column="1" Grid.Row="1" Content="Search" Click="Search_Click" />
        <StackPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Orientation="Horizontal">
            <RadioButton x:Name="searchAllRadio" GroupName="searchTypeGroup" Content="All" Margin="10 3 0 0" IsChecked="true" Click="searchRadio_Click"></RadioButton>
            <RadioButton x:Name="searchWebRadio" GroupName="searchTypeGroup" Content="Webpages only" Margin="20 3 0 0" Click="searchRadio_Click"></RadioButton>
            <RadioButton x:Name="searchImageRadio" GroupName="searchTypeGroup" Content="Images only" Margin="20 3 0 0" Click="searchRadio_Click"></RadioButton>
        </StackPanel>
        
        <ListBox Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2" x:Name="resultList" Width="590">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Vertical" Width="580">
                        <HyperlinkButton TargetName="_blank" 
                            NavigateUri="{Binding Path=url}" 
                            Content="{Binding Path=name}" Foreground="Blue" />
                        <TextBlock Text="{Binding description}" TextWrapping="Wrap" />
                        <TextBlock Text="{Binding tags}" Foreground="DarkMagenta" TextWrapping="Wrap" />
                        <TextBlock Text="{Binding summary}" Foreground="Green" FontSize="10" />
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>




        <Grid x:Name="Spinner" Grid.Column="0" Grid.Row="3" Visibility="Collapsed">
            <Grid.RenderTransform>
                <ScaleTransform x:Name="SpinnerScale" ScaleX="0.5" ScaleY="0.5" />
            </Grid.RenderTransform>
            <Canvas RenderTransformOrigin="0.5,0.5" Width="120" Height="120">
                <Ellipse Width="21.835" Height="21.862" Canvas.Left="20.1696" Canvas.Top="9.76358" 
            Stretch="Fill" Fill="#E6FCBE54"/>
                <Ellipse Width="21.835" Height="21.862" Canvas.Left="2.86816" Canvas.Top="29.9581" 
            Stretch="Fill" Fill="#CDFCBE54"/>
                <Ellipse Width="21.835" Height="21.862" Canvas.Left="5.03758e-006" Canvas.Top="57.9341" 
            Stretch="Fill" Fill="#B3FCBE54"/>
                <Ellipse Width="21.835" Height="21.862" Canvas.Left="12.1203" Canvas.Top="83.3163" 
            Stretch="Fill" Fill="#9AFCBE54"/>
                <Ellipse Width="21.835" Height="21.862" Canvas.Left="36.5459" Canvas.Top="98.138" 
            Stretch="Fill" Fill="#80FCBE54"/>
                <Ellipse Width="21.835" Height="21.862" Canvas.Left="64.6723" Canvas.Top="96.8411" 
            Stretch="Fill" Fill="#67FCBE54"/>
                <Ellipse Width="21.835" Height="21.862" Canvas.Left="87.6176" Canvas.Top="81.2783" 
            Stretch="Fill" Fill="#4DFCBE54"/>
                <Ellipse Width="21.835" Height="21.862" Canvas.Left="98.165" Canvas.Top="54.414" 
            Stretch="Fill" Fill="#34FCBE54"/>
                <Ellipse Width="21.835" Height="21.862" Canvas.Left="92.9838" Canvas.Top="26.9938" 
            Stretch="Fill" Fill="#1AFCBE54"/>
                <Ellipse Width="21.835" Height="21.862" Canvas.Left="47.2783" Canvas.Top="0.5" 
            Stretch="Fill" Fill="#FFFCBE54"/>
                <Canvas.RenderTransform>
                    <RotateTransform x:Name="SpinnerRotate" Angle="0" />
                </Canvas.RenderTransform>
                <Canvas.Triggers>
                    <EventTrigger RoutedEvent="ContentControl.Loaded">
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation Storyboard.TargetName="SpinnerRotate" 
                                 Storyboard.TargetProperty="(RotateTransform.Angle)" 
                                 From="0" To="360" Duration="0:0:01" 
                                 RepeatBehavior="Forever" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </Canvas.Triggers>
            </Canvas>
        </Grid>

    </Grid>
</UserControl>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Australia Australia
-- ooo ---
www.conceptdevelopment.net
conceptdev.blogspot.com
www.searcharoo.net
www.recipenow.net
www.racereplay.net
www.silverlightearth.com

Comments and Discussions