coder coder - 1 year ago 53
Javascript Question

Disable <li> tag based on value of a key in web.config file


string fblink = WebConfigurationManager.AppSettings["facebook"];
if (fblink == "")
//need code to disable <li>


<div >
<li id="face">
<a id="fb" runat="server" target="_blank" href="<%$ AppSettings:facebook %>"></a>

In web.config file added a key named facebook with value.

If this value is empty the li tag should disable

Answer Source

If you want to access the <li> in back-end means you should give runat="server" as tag attribute. if so The li will looks like the following:

<li id="face" runat="server"> .. </li>

So that you can access them like this:

if (fblink == "")

By using javascript:

var fblink = '<%= System.Configuration.ConfigurationManager.AppSettings["facebook"].ToString() %>';
if (fblink == "")
  var liElement =  document.GetElementByID("face"); = 'none';