如题:
后台:
protected string CutString(string str, int length)
{
string newString = "";
if (str != "")
{
if (str.Length > length)
{
newString = str.Substring(0, length) + "...";
}
else
{
newString = str;
}
}
return newString;
}
有这么一个方法!前台:
我用TextBox 调用
<asp:TextBox ID="TextBox1" runat="server" Text='<%# CutString(Eval("NewTitle").ToString(),5) %>'></asp:TextBox>
这么写有什么不对吗!为什么一运行不截取呢! 请高手指点一下!在这里谢过了!注:在Web应有程序中!
后台:
protected string CutString(string str, int length)
{
string newString = "";
if (str != "")
{
if (str.Length > length)
{
newString = str.Substring(0, length) + "...";
}
else
{
newString = str;
}
}
return newString;
}
有这么一个方法!前台:
我用TextBox 调用
<asp:TextBox ID="TextBox1" runat="server" Text='<%# CutString(Eval("NewTitle").ToString(),5) %>'></asp:TextBox>
这么写有什么不对吗!为什么一运行不截取呢! 请高手指点一下!在这里谢过了!注:在Web应有程序中!
解决方案 »
- vs2010打开vs2008的项目,提示找不到System.Web.Silverlight
- 问问 prototype.js 框架的问题
- 邮件附件发送失败
- asp.net后台动态生成控件,出现问题
- 关于DropDownList的AppendDataBoundItem属性遇到AJAX的问题,急..................!!!
- 问个问题,希望高手帮忙解决一下
- Request.UserHostAddress 的格式问题
- 请问如何在水晶报表中根据某个字段的值是否为空来显示某条线的显示与否?
- 网站打不开。。。
- 请教:关于向ACCESS中写数据的问题
- 如何在客户端javacript里设置ultrawebcombo不可见
- forms验证为什么要用身份验证票 直接用一个cookie保存不行吗?
这句话有用么,为什么不直接在后台掉用那个方法呢?
public void Initaa()
{ // 新建一个TimerCallback委托,具体要执行的方法在ScheduledWorkCallbackEmailInterval中
emailTimer = new Timer(new TimerCallback(ScheduledWorkCallbackEmailInterval), null, 5000, 2000);
} /**//// <summary>
/// 释放定时器
/// </summary>
public void displose()
{
statsTimer = null;
emailTimer = null;
} /**//// <summary>
/// 定时任务
/// </summary>
private void ScheduledWorkCallbackEmailInterval (object sender)
{
try
{
StreamWriter sw;
string Path = Server.MapPath(".");
int last = Server.MapPath(".").LastIndexOf("\\");
Path = Path.Substring(0,last)+"\\index.txt";
if(!File.Exists(Path))
{
FileStream fs = File.Create(Path);
sw = new StreamWriter(Path,false,System.Text.Encoding.GetEncoding("gb2312"));
}
else
{
sw = new StreamWriter(Path,true,System.Text.Encoding.GetEncoding("gb2312"));
}
sw.WriteLine("!");
sw.WriteLine("!");
sw.WriteLine("!");
sw.WriteLine("------------"+DateTime.Now.ToString()+"----------------");
sw.Close();
}
catch
{
Response.Write(2);
}
finally
{
emailTimer.Change( 5000, 5000 );
}
} //// <summary>
/// 定时休眠
/// </summary>
private void ScheduledWorkCallbackStatsInterval(object sender)
{
try
{
// 休眠定时器
statsTimer.Change( System.Threading.Timeout.Infinite, 2000 );
}
catch( Exception e )
{ }
finally
{
// 唤醒定时器
statsTimer.Change( 5000, 2000);
}
} 最后调用Initaa() 这个函数就可以了。作用是给文本文件中每个5秒写一次数据济南网站建设 http://www.dttit.com
load 怎么能写方法呢!
protected string CutString(object str, object length)
{
string newString = "";int lengthi=Convert.ToByte(length.ToString());
if (str.ToString() != "")
{
if (str.ToString().Length > lengthi)
{
newString = str.ToString().Substring(0, lengthi) + "...";
}
else
{
newString = str.ToString().;
}
}
return newString;
}
有这么一个方法!前台:
我用TextBox 调用
<asp:TextBox ID="TextBox1" runat="server" Text=' <%# CutString(Eval("NewTitle").ToString(),"5") %>'> </asp:TextBox>
我用TextBox 调用
<asp:TextBox ID="TextBox1" runat="server" Text=' <%# CutString(Eval("NewTitle"),"5") %>'> </asp:TextBox>
我用TextBox 调用
<asp:TextBox ID="TextBox1" runat="server" Text=' <%# CutString(DataBinder.Eval("NewTitle"),"5") %>'> </asp:TextBox>