<asp:CommandField DeleteText="<div id=div1 onclick="javascript:return confirm('Are you sure to delete?')">×</div>" ShowDeleteButton="True">我的asp.net 有這樣一句,我想把are you sure to delete?這個句與Resource中的資源綁定,我該如何寫??因為這個網站有幾個語言版本,英語,中文,日文
像一些textBox的text就直接這樣寫就行了TextBox.text="<%$ Resources:lang,PropertyDetails%>"
像一些textBox的text就直接這樣寫就行了TextBox.text="<%$ Resources:lang,PropertyDetails%>"
if
else if
else
如果是GridView
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//[0]改为具体列的索引,xxx改为资源文件中的值
e.Row.Cells[0].Attributes.Add("onclick",string.Format("return confirm('{0}')",xxx);
}
}
首先在App_GlobalResources新建resx资源文件。
<asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:lang,userinfo%>" />
或者
<%=Resources.lang.userinfo%>
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(Request.Cookies["lang"].Value.ToString());
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Request.Cookies["lang"].Value.ToString());
}