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..
5 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sanjeeb LenkaPosted Oct 1, 2013, 12:28 AM
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();
}
hanna matsudairaPosted Oct 2, 2013, 11:18 PM
Sunny SharmaPosted Oct 1, 2013, 1:21 AM
-------------------------------------
-------------------------------------
HTH :)
hanna matsudairaPosted Sep 30, 2013, 9:29 PM
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 SharmaPosted Sep 30, 2013, 12:46 AM
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 :)