为什么文本的方向没有改变?
Why the direction of text is not getting changed ?
我正在尝试根据下拉列表的 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();");
}
我正在尝试将其从 'left to right' 更改为 'right to left'
您应该也可以使用 Controls Style Property 在您的事件处理程序中更改它;类似下面
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
this.TextBox1.Style["textAlign"] = "right";
}
我正在尝试根据下拉列表的 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();");
}
我正在尝试将其从 'left to right' 更改为 'right to left'
您应该也可以使用 Controls Style Property 在您的事件处理程序中更改它;类似下面
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
this.TextBox1.Style["textAlign"] = "right";
}