Navigation

Search

Categories

On this page

jQuery Slideshow Cycle Plugin
Using jQuery to Return a Gridview as an AJAX Response
Using jQuery with ASP.NET
Providing Scalability for ASP.NET Applications

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 240
This Year: 46
This Month: 3
This Week: 0
Comments: 0

Sign In
Pick a theme:

# Tuesday, May 19, 2009
Tuesday, May 19, 2009 8:21:02 PM (GMT Daylight Time, UTC+01:00) ( jQuery )


The number of plugins for jQuery popping up all over has been great. If you’re thinking of doing a specific task with jQuery, chances are there’s already a plugin for it.

The jQuery Slideshow Cycle plugin offers an interesting way to display a series of photos. This plugin makes it very easy to display a group of photos similar to a slideshow.

Here is my working example and source code.  I’ve added the ability to select what effect to apply to the pictures through a selectbox.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery Picture Cycler</title>
<script type="text/javascript" src="jquery/jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="jquery/jquery.cycle.all.min.js"></script>

<script type="text/javascript">

function pageLoad() {
    getEffect('cover');
}

function ddlEffect_onChange() {
    var effect = document.getElementById("ddlEffect"); 
    var selText = effect.options[effect.selectedIndex].text;
    getEffect(selText);
}

$(document).ready(function getEffect(selText){
    $('#myslides').cycle({
        fx: selText,
        speed: 500,
        timeout: 2000
    });
});

</script>

<style type="text/css">

#myslides {
    width: 370px;
    height: 220px;
    padding: 0;
    margin:  0 auto;
} 

#myslides img {
    padding: 10px;
    border:  1px solid rgb(100,100,100);
    background-color: rgb(230,230,230);
    width: 350px;
    height: 200px;
    top:  0;
    left: 0
}
</style> 
</head>

<body onload="pageLoad();">

Select an effect type:<br/>
 <select name="ddlEffect" id="ddlEffect" onchange="ddlEffect_onChange();">
                <option value="blindX" selected>blindX</option>
                <option value="blindY">blindY</option>
                <option value="blindZ">blindZ</option>
                <option value="cover">cover</option>
                <option value="curtainX">curtainX</option>
                <option value="curtainY">curtainY</option>
                <option value="fade">fade</option>
                <option value="fadeZoom">fadeZoom</option>
                <option value="growX">growX</option>
                <option value="growY">growY</option>
                <option value="scrollUp">scrollUp</option>
                <option value="scrollDown">scrollDown</option>
                <option value="scrollLeft">scrollLeft</option>
                <option value="scrollRight">scrollRight</option>
</select>
 <br/>
<div id="myslides">
 <img src="/images/capitol.jpg" width="350" height="200" />
 <img src="/images/flowers.jpg" width="350" height="200" />
 <img src="/images/countryscene.jpg" width="350" height="200" /> 
</div>

</body>
</html>
Comments [0] | | # 
Tuesday, May 19, 2009 4:28:35 PM (GMT Daylight Time, UTC+01:00) ( jQuery )


This is a cool example of how to return the results of a search formatted as a Gridview using the jQuery ajaxForm method.

Here is a working example

>> jquery.contact.form.response.aspx

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery Form</title>
<script type="text/javascript" src="jquery/jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="jquery/jquery.form.js"></script>


<script type="text/javascript">

// prepare the form when the DOM is ready 
$(document).ready(function() { 
    // bind form using ajaxForm 
    $('#htmlForm').ajaxForm({ 
        // target identifies the element(s) to update with the server response 
        target: '#htmlExampleTarget', 
 
        // success identifies the function to invoke when the server response 
        // has been received; here we apply a fade-in effect to the new content 
        success: function() { 
            $('#htmlExampleTarget').fadeIn('5000'); 
        } 
    }); 
});

</script>
</head>

<body>
<form id="htmlForm" action="jquery.contact.form.response.gridview.aspx" method="post"> 
    Movie Search: <input type="text" name="title" value="Truth" /> 
    <input type="submit" value="Search Movies" /> 
</form>
Suggestions: "truth","attack","an","space"<br /><br />

<div id="htmlExampleTarget"></div>

</body>
</html>

>> jquery.contact.form.response.gridview.aspx

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<script runat="server">
    Sub Page_Load()

        If Not Page.IsPostBack Then
            Dim strTitle As String = Request("title")
            lblTitle.Text = strTitle
        
            BindGridView(strTitle, "Title")
        End If

    End Sub
    
    Sub BindGridView(ByVal strTitle As String, ByVal strSortOrder As String)
        
        Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("MyDatabase").ConnectionString)
        Dim strSqlText As String = "SELECT Title, Director FROM Movies WHERE Title LIKE '%" & strTitle & "%' ORDER BY " & strSortOrder

        Dim cmd As New SqlCommand(strSqlText)
        con.Open()
        cmd.Connection = con

        dgMovies.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection)
        dgMovies.DataBind()

        con.Close()
        con.Dispose()
        
    End Sub
    
    Sub SortGridView(ByVal Sender As Object, ByVal e As GridViewSortEventArgs)
        BindGridView(lblTitle.Text, e.SortExpression.ToString())
    End Sub
       
</script>

<html>
<head><title></title>
</head>
<body>

<form runat="server">

<asp:gridview runat="server" CellPadding="4" 
ForeColor="#333333" GridLines="None" 
AllowSorting="true" OnSorting="SortGridView"
id="dgMovies" Width="80%" 
HorizontalAlign="Center" 
Font-Names="Tahoma" 
Font-Size="Small" 
EmptyDataText="No records were found">
    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />    
    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:gridview>

<asp:Label ID="lblTitle" runat="server" Visible="false" />

</form>

</body>
</html>
Comments [0] | | # 
Tuesday, May 19, 2009 4:11:42 PM (GMT Daylight Time, UTC+01:00) ( jQuery )


Visual Studio 2008 SP1 and Visual Web Developer Express SP1 now support intellisense for jQuery. 

Assuming you have installed the hotfix , downloaded the jQuery library and the jQuery VS 2008 IntelliSense documentation, follow these steps to move ahead.

Open Visual Studio 2008 > File > New > Website > Choose ‘ASP.NET 3.5 website’ from the templates > Choose your language (C# or VB) > Enter the location > Ok. In the Solution Explorer, right click your project > New Folder > rename the folder as ‘Scripts’.

Right click the Scripts folder > Add Existing Item > Browse to the path where you downloaded the jQuery library (jquery-1.3.2.js) and the intellisense documentation (jquery-1.3.2-vsdoc.js) > Select the files and click Add.

Here is a working example of the code below.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Page Language="VB" %>
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>Learning jQuery</title>

<script type="text/javascript" src="jquery/jquery-1.3.min.js"></script>
<script type="text/javascript" src="jquery/jquery-1.3.2-vsdoc2.js"></script>

<style type="text/css">
        div { 
        background-color:#D5EDEF; 
        color:#4f6b72;
        width:50px; 
        border: 1px solid #C1DAD7; 
 
      }
</style>
 
<script type="text/javascript">
        $(document).ready(function() {
            $("#Button1").click(function() {
                alert("Hello world!");
            }); 
            
            $("#btnAnimate").click(function() {
             $("#Panel1").animate(
            {
                width: "350px",
                opacity: 0.5,
                fontSize: "16px"
            }, 1800);
         });
        });
</script>
    
</head>

<body>

<form id="form1" runat="server">

<asp:Button runat="server" Text="Button" id="Button1" /><br /><br />

<input id="btnAnimate" type="button" value="Animate" />
<asp:Panel ID="Panel1" runat="server">
        Some sample text in this panel        
</asp:Panel>
        
</form>

</body>

</html>
Comments [0] | | # 
# Monday, May 04, 2009
Monday, May 04, 2009 6:36:02 PM (GMT Daylight Time, UTC+01:00) ( ASP.NET )
This is one the better articles I've ever seen on this topic. TechNet magazine provides a great high-level overview on scaling your ASP.NET apps.

http://technet.microsoft.com/en-us/magazine/dd797568.aspx

Comments [0] | | #