-------------------------------------------------后台调用前台的JS方法------------------------------------------------------- ClientScript.RegisterStartupScript(this.GetType(), "s", "<script>method();</script>");
if (confirm("添加成功!是否继续添加?")==true) //弹出确认框
页面:
function method()
{
if (confirm("添加成功!是否继续添加?")==true)
{
ClearInput();
}else
{
closeWin();
}
}
-----------输入框不可写,并且后台能够取到值的写法:contentEditable="false" style="color:Gray" --------
<asp:TextBox ID="txtMoney" runat="server" CssClass="inputfiled" MaxLength="8" Width="150px" contentEditable="false" style="color:Gray" ></asp:TextBox><span>*</span>
-----------------------------按字符串实际长度截取定长字符串-CutString-----------
<asp:TemplateField HeaderText="报警类型">
<ItemTemplate>
<asp:Label ID="DDate" runat="server" Text='<%# CutString(Eval("AlarmName").ToString(),80)%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
--------------------------------------打开Visual Studio 代码提示功能 ----------------------------------------------------
依次选 《工具》 --->《选项》 ---> 《文本编辑器》 ---> 《C#》 ---> 《常规》--->《语句结束》栏目下的《自动列出成员》《参数信息》都勾选住就可以了。
/// <summary>
/// 按字符串实际长度截取定长字符串
/// </summary>
/// <param name="str">原字符串</param>
/// <param name="length">要截取的长度</param>
/// <returns>string型字符串</returns>
public static string CutString(string str, int length)
{
string delsqace = str.Trim();
int i = 0, j = 0;
foreach (char chr in delsqace)
{
if ((int)chr > 127)
{
i += 2;
}
else
{
i++;
}
if (i > length)
{
delsqace = delsqace.Substring(0, j) + "...";
break;
}
j++;
}
return delsqace;
}