如何在Web用户控件中的运行时更改元素属性? [英] How to change element attribute at runtime in Web user control?

查看:90
本文介绍了如何在Web用户控件中的运行时更改元素属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面的Web用户控制菜单.现在我希望菜单中的HOME文本在default.aspx已加载(加载事件)时变为粗体!
如果有人可以提供代码,我该怎么办!我在后面使用VB .Net.

<%@控制语言="VB" AutoEventWireup ="false" CodeFile ="menuwuc.ascx.vb" Inherits ="menuwuc"%>
< link href ="menustyle.css" rel ="stylesheet" type ="text/css"/>
< center>
< div>
< img src ="image1.gif" height ="100px" width ="902px"/>
</div>
< table width ="902px" border ="0" cellpadding ="0" cellspacing ="0" background ="img/header-background1.gif">
< tr>
< td width ="80px" class ="menu" align ="center">< a href =#" class ="menu" title =教程首页"> HOME</a></td>
< td width ="80px" class ="menu" align ="center">< a href =#" class ="menu" title ="HTML教程">关于我们</a></td>
< td width ="80px" class ="menu" align ="center">< a href =#" class ="menu" title ="CSS教程">新变化</a></td>
< td width ="80px" class ="menu" align ="center">< a href =#" class ="menu" title ="SQL教程">服务</a></td> ;
</tr>
</table>
</center>

I have a web user control menu of page. Now I want HOME text in menu to be Bold at the time default.aspx Loaded (Load event)!
How can I do that If any one can provide code! I am using VB .Net at back.

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="menuwuc.ascx.vb" Inherits="menuwuc" %>
<link href="menustyle.css" rel="stylesheet" type="text/css" />
<center>
<div >
<img src="image1.gif" height="100px" width="902px"/>
</div>
<table width="902px" border="0" cellpadding="0" cellspacing="0" background="img/header-background1.gif">
<tr>
<td width="80px" class="menu" align="center"><a href="#" class="menu" title="Tutorial home page">HOME</a></td>
<td width="80px" class="menu" align="center"><a href="#" class="menu" title="HTML tutorial">about us</a></td>
<td width="80px" class="menu" align="center"><a href="#" class="menu" title="CSS tutorial">Whats New</a></td>
<td width="80px" class="menu" align="center"><a href="#" class="menu" title="SQL tutorial">Services</a></td>
</tr>
</table>
</center>

推荐答案

Sunil Tarwara

由于您使用的是纯HTML即
Sunil Tarwara

Since you are using the plain HTML i.e.
a href="#" class="menu" title="Tutorial home page">HOME

,甚至没有添加htmlcontrols,所以我觉得很难做到这一点.

我建议使用控件(HTML或ASP),以便您可以处理后面的代码.

without adding even the htmlcontrols, I feel it is difficult to do that.

I suggest to use the controls (either HTML or ASP), so that you can handle at code behind.


这篇关于如何在Web用户控件中的运行时更改元素属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆