I'm totally new to using jquery and I found a jquery truncate plugin
that I'm using here: http://reindel.com/truncate/

I have the truncate plugin working, but I have two questions in
regards to modifying this plugin to suit my needs.

Here is the scenario, I have a formview on my page that is bound
declaratively using an ObjectDataSource.  Due to screen real estate,
not all the data in the formview can be displayed at once.  It expands
beyond the height of the div and cannot be seen.

I'm using the jquery truncate plugin to show the first 500 characters,
which works fine.  However, when I click the more link, jquery display
all the data in the formview which again displays below the specified
height of the div and you cannot see all the content.

So, what I'm hoping is possible is to modify the jquery plugin so, it
can show the first 500 characters as it currently does and then when
you click the "more" link it will show the next 500, etc.  Basically,
page thru the content in 500 character chunks.

My second question is much simpler and that is if it is possible to
modify the "more" and "previous" links so they are positioned right
after the 500 character?  currently, it has a line-break.

Being new to jquery, I'm kind of lost as to how to modify this plugin
to fit my needs.

see below for my code:

aspx page code:

<%@ Page Title="Dwayne Epps :: Bio" Language="C#" MasterPageFile="~/
Site.master" AutoEventWireup="true" CodeFile="About.aspx.cs"
Inherits="About" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="topleft"
Runat="Server">
    <asp:Image ID="Image2" runat="server" ImageUrl="~/images/
D2photo.jpg" />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="topright"
Runat="Server">
   <asp:FormView ID="FormView1" runat="server"
DataSourceID="ObjectDataSource1">
        <ItemTemplate>
            <h4><asp:Label ID="item_titleLabel" runat="server" Text='<
%# Bind("item_title") %>' /></h4>
            <asp:Label ID="item_bodyLabel" runat="server" Text='<%#
Bind("item_body") %>' />
        </ItemTemplate>
    </asp:FormView>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
        OldValuesParameterFormatString="original_{0}"
        SelectMethod="GetWebItemBySitekey"
TypeName="Library.BLL.WebItemBL">
        <SelectParameters>
            <asp:QueryStringParameter Name="sitekey"
QueryStringField="sitekey"
                Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="bottomleft"
Runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="bottomright"
Runat="Server">
</asp:Content>

aspx.cs code-behind:

protected void Page_Load(object sender, EventArgs e)
    {
        LoadScript();
    }

    protected void LoadScript()
    {
        ClientScriptManager csm = Page.ClientScript;
        StringBuilder sb = new StringBuilder();

        sb.Append("\n");
        sb.Append("<script language=\"javascript\" type=\"text/
javascript\">\n");
        sb.Append("$(function() {\n");
        sb.Append("$(\".AspNet-FormView\").truncate(650, {\n");
        sb.Append("chars: /\\s/,\n");
        sb.Append("trail: [ \" ( <a href='#'
class='truncate_show'>more</a> . . . )\", \" ( . . . <a href='#'
class='truncate_hide'>previous</a> )\" ]\n");
        sb.Append("});\n");
        sb.Append("});\n");
        sb.Append("</script>");

        csm.RegisterClientScriptBlock(this.GetType(), "sLoadString",
sb.ToString());

    }

Thanks for any help.
Regards.

Reply via email to