I am using this code
<%-- --%>
but it doesn't work at all..
I want my book synopsis to be a limit of 100 characters and if it exceeds the 'read more' will be shown and be directed in 'details page'.
,.please help me. Thank you..
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Sep 30, 2013, 8:28 PM EDT
try like this. it may help you
Tooltip='<%# Eval("BookSynopsis") %>'>
Visible='<%# SetVisibility(Eval("BookSynopsis"), 100) %>'
OnClick="ReadMoreLinkButton_Click">
And code-behind
protected bool SetVisibility(object Desc, int length)
{
return Desc.ToString().Length > length;
}
protected void ReadMoreLinkButton_Click(object sender, EventArgs e)
{
LinkButton button = (LinkButton)sender;
GridViewRow row = button.NamingContainer as GridViewRow;
Label descLabel = row.FindControl("Label1") as Label;
button.Text = (button.Text == "Read More") ? "Hide" : "Read More";
string temp = descLabel.Text;
descLabel.Text = descLabel.ToolTip;
descLabel.ToolTip = temp;
}
//including the original helper from the question with changes in signature
protected string Limit(object Desc, int length)
{
StringBuilder strDesc = new StringBuilder();
strDesc.Insert(0, Desc.ToString());
if (strDesc.Length > length)
return strDesc.ToString().Substring(0, length) + "..." + [Read More];
else return strDesc.ToString();
}
Sunny SharmaRank #223 · 11.1K reputationPosted Sep 29, 2013, 8:46 PM EDT
See your code:
-------------------------------------
<%--
-------------------------------------
Probably you've missed to put () after ToString which is causing the issue. You can modify it to ToString().Sub... and it will work.
EDIT 1:
Try this code:
-------------------------------------
-------------------------------------
Happy Coding :)
hanna matsudaira6 reputationPosted Sep 30, 2013, 5:29 PM EDT
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.Compiler Error Message: CS1001: Identifier expected
Source Error:
Source File: c:\Users\Kon\Documents\Visual Studio 2010\Projects\MimiKo\MimiKo\User\MangaList.aspx Line: 122
//This is the error without the ToString()..
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.Compiler Error Message: CS1002: ; expected
Source Error:
Source File: c:\Users\Kon\Documents\Visual Studio 2010\Projects\MimiKo\MimiKo\User\MangaList.aspx Line: 120
//This is the error with the 'ToString()' and I've tried to put the '()' in the ToString before SubString, but still no luck..
,,
Please help me, where is the error?
Sunny SharmaRank #223 · 11.1K reputationPosted Sep 30, 2013, 9:21 PM EDT
-------------------------------------
-------------------------------------
HTH :)
hanna matsudaira6 reputationPosted Oct 2, 2013, 7:18 PM EDT