URGENT !! ASP.NET and Javascript !! How to use java script in asp server controls ?

Posted by .Netlearner under ASP.NET on 6/20/2012 | Points: 10 | Views : 854 | Status : [Member] | Replies : 1
Am having a list item (li) for which am assgining the values dynamically.And while the particular item is selected i want that top be highlighted.

i Used Following Code to do this but as am using runat="server" its not applied.if i removed the runat="server" Javascript is working good .But Li is not treated as a server control anymore and its not enabled in the code behind file.So i cant remove the runat="server" attribute also.

How This can be done.

<li id="adminabout"><asp:LinkButton ID="lbtnadminabout3" runat="server" OnClick="OnClick1" CausesValidation="false"></asp:LinkButton></li>
<li id="admingeneral"><asp:LinkButton ID="lbtnadmingeneral" runat="server" CausesValidation="false" OnClick="OnClick2"></asp:LinkButton></li>

<script type="text/javascript">
function select1()
{
document.getElementById("adminabout").className="selected";
}
function select2()
{
document.getElementById("admingeneral").className="selected";
}
function select3()
{
document.getElementById("admincategory").className="selected";
}
</script>





Responses

Posted by: Hitesh.Hirpara on: 6/20/2012 [Member] Starter | Points: 25

Up
0
Down
Source Co de

<body>
<form id="form1" runat="server">
<div>
<li id="adminabout" runat="server">
<asp:LinkButton ID="lbtnadminabout3" runat="server" CausesValidation="false"
onclick="lbtnadminabout3_Click"></asp:LinkButton></li>
<li id="admingeneral" runat="server">
<asp:LinkButton ID="lbtnadmingeneral" runat="server" CausesValidation="false"
onclick="lbtnadmingeneral_Click"></asp:LinkButton></li>
</div>
</form>
</body>


code beh ind
protected void lbtnadminabout3_Click(object sender, EventArgs e)
{
adminabout.Attributes.Add("class", "selected");
}

protected void lbtnadmingeneral_Click(object sender, EventArgs e)
{
admingeneral.Attributes.Add("class", "selected");
}


try this

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response