jquery - How to add class in parent li using child link button from code behind in asp.net c#? -
here html code page :
<ul class="list quicker"> <li><asp:linkbutton runat="server" id="education_news" onclick="education_news_click" >education</asp:linkbutton></li> <li><asp:linkbutton runat="server" id="immigration_news" onclick="immigration_news_click">immigration</asp:linkbutton></li> <li><asp:linkbutton runat="server" id="visa_news" onclick="visa_news_click" >visa</asp:linkbutton></li> </ul>
here code behind page i've used:
protected void education_news_click(object sender, eventargs e) { string edu = education_news.text; using (sqlconnection _con = new sqlconnection(_data.cs)) { sqlcommand _cmd = new sqlcommand("select * tbl_brochures type=@type", _con); _cmd.parameters.addwithvalue("@type", edu); _con.open(); dl_brochures.datasource = _cmd.executereader(); dl_brochures.databind(); } }
i have when click on link button parent li of link button should change or add class li(this). have query got no solution.
you need add runat="server"
li
in aspx:
<ul class="list quicker"> <li runat="server"><asp:linkbutton runat="server" id="education_news" onclick="education_news_click" >education</asp:linkbutton></li> <li runat="server"><asp:linkbutton runat="server" id="immigration_news" onclick="immigration_news_click">immigration</asp:linkbutton></li> <li runat="server"><asp:linkbutton runat="server" id="visa_news" onclick="visa_news_click" >visa</asp:linkbutton></li> </ul>
and add class in code-behind:
protected void education_news_click(object sender, eventargs e) { ((htmlgenericcontrol) education_news.parent).attributes["class"] = "some-class"; }
Comments
Post a Comment