1、实现输入框在图片之上,并且有默认的提示文字。详见下面的设置,placeholder是设置提示文字,position:relative;top:-166px;left:18px设置相对位置,z-index设置相对层级。
<asp:panel id="pnl" runat="server">
<asp:Image ID="Image1" runat="server" ImageUrl ="~/Images/steels/SectionWeldImage/H型钢.png" Height="322px" ImageAlign="Top" Width="302px" />
<br />
<asp:TextBox ID="htxt" runat="server" placeholder="h" style ="position:relative;top:-166px;left:18px;z-index:1;width:40px" Height="8px" ></asp:TextBox>
<asp:TextBox ID="btxt" runat="server" placeholder="b" style ="position:relative;top:-312px;left:60px;z-index:1;width:40px" Height="8px" ></asp:TextBox>
</asp:panel>
2、菜单项设置图片在上,文字在下。文字前加<br>即可。
<Items>
<asp:MenuItem
Text="<br>H型钢" Value="0" ImageUrl="../Images/steels/SectionWeld/H型钢2.png"></asp:MenuItem>
<asp:MenuItem ImageUrl="../Images/steels/SectionWeld/不等边H型1.png"
Text="<br>不等边H型" Value="1"></asp:MenuItem>
</Items>
3、通过名称来取得页面上的控件并设置控件属性。在panel控件上使用FindControl方法即可。
Control ctrl = pnl.FindControl(textboxnames[i]);
if (isshow[CurrentItemID][i])
{ ((TextBox)ctrl).Attributes.Add("style", "position:relative;top:" + top[CurrentItemID][i] + "px; left:" + left[CurrentItemID][i] + "px;z-index:1;width:40px"); ((TextBox)ctrl).Visible = true; }
else
((TextBox)ctrl).Visible = false;
4、ASP.NET以编程方式设置GridView标题行文字等,以声明方式设置AutogenerateColumns为true
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
switch (e.Row.Cells[i].Text)
{
case "截面积":
{
e.Row.Cells[i].Text = "截面积(cm2)";
break;
}
case "重量":
{
e.Row.Cells[i].Text = "重量(kg/m)";
break;
}
case "表面积":
{
e.Row.Cells[i].Text = "表面积(m2/m)";
break;
}
}
}
} }


评论0