【发布时间】:2015-10-23 02:52:28
【问题描述】:
我试图在下拉的 selectedIndexChanged 事件时更改文本框的方向(文本方向)但不起作用。
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Text="Select" Selected="True"></asp:ListItem>
<asp:ListItem Text="English" Value="Eng"></asp:ListItem>
<asp:ListItem Text="Persian" Value="fa"></asp:ListItem>
</asp:DropDownList>
JS:
<script type="text/javascript">
function ChangeTextDirection()
{
document.getElementById("TextBox1").style.textAlign="right";
return false;
}
</script>
事件:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList1.Attributes.Add("onchange", "ChangeTextDirection();");
}
我正在尝试将其从“从左到右”更改为“从右到左”
【问题讨论】:
-
设置样式“direction:RTL;”从右到左。
-
但样式元素存在于客户端,但我必须从服务器端更改它,即 selectedIndexChanged 事件
标签: c# asp.net .net c#-4.0 webforms