Active navigation menu for current url

Set the active/current menu link based or Url in Jquery:

suppose we have menu like:

<div class="nav">

 <ul>
 <li class="active"><a href="~/url1/">URL 1</a>
 <li><a href="~/url2/">URL 2</a>
 <li><a href="~/url3/">URL 3</a>
 </ul>

</div>
and user when clicked on URL 2 then item look as active :

$(function(){

    var url = window.location.pathname, 
    urlRegExp = new RegExp(url.replace(/\/$/,'') + "$"); 

     $('#nav a').each(function(){
            if(urlRegExp.test(this.href.replace(/\/$/,''))){
                $(this).addClass('active');
            }
        });

});

Edited version

$(document).ready(function() {
var str = location.href.toLowerCase();
$(".ddsmoothmenu li a").each(function() {
if (str.indexOf(this.href.toLowerCase()) > -1) {
$("li.active").removeClass("active");
$(this).parent().addClass("active");
}
});
});

Advertisements
Posted in Uncategorized

Wrap Label Text in asp.net

Today I found one issue with my site, that is a label text was not wrapped and display continued. Found finally working solution:

 <div style="float:left;overflow-y:auto;overflow-x:auto; word-break:break-all;">
	<asp:Label ID="lbDesc" runat="server" />
</div>
Tagged with: ,
Posted in Asp.Net

asp.net 4.0 web form routing in iis7

Today I have completed my first phase of the project on Asp.Net 4.0 and I have implemented Web Form routing feature. It was working fine on VS inbuilt IIS server but when I deployed on IIS server, it was not working. I did little bit search on Google and finally found working solution. It may help you in future.

<modules runAllManagedModulesForAllRequests="true">
      <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule,
                    System.Web, Version=4.0.0.0, Culture=neutral,
                    PublicKeyToken=b03f5f7f11d50a3a" />      
    </modules>
    <handlers>
      <add
            name="UrlRoutingHandler"
            preCondition="integratedMode"
            verb="*" path="UrlRouting.axd"
            type="System.Web.HttpForbiddenHandler, System.Web,  
              Version=2.0.0.0, Culture=neutral,  
              PublicKeyToken=b03f5f7f11d50a3a"/>
    </handlers>

Tagged with: ,
Posted in Asp.Net, IIS7

RadioButtonList change event in jquery

Trap RedioButtonList change event in Jqury OR RadioButtonList selected value in Jquery:

<asp:RadioButtonList ID="rblBannerType" ClientIDMode="Static" runat="server" 
              RepeatDirection="Horizontal" >
    <asp:ListItem Value="image" Selected="True">Image</asp:ListItem>
    <asp:ListItem Text="html" >Html</asp:ListItem>
</asp:RadioButtonList> 

//jquery script
<script>
	$(function () {
		var t = $("#rblBannerType input:checked").val();
		SetBannerType(t);

		//Banner Type
		$("#rblBannerType").change(function () {
			var type = $("#rblBannerType input:checked").val();
			SetBannerType(type);
		});
	});
	function SetBannerType(type) {
		if (type == "image") {
			$("#divImage").show();
			$("#divHtml").hide();
		}
		else {
			$("#divHtml").show();
			$("#divImage").hide();
		}
	}
</script>
Tagged with: ,
Posted in Asp.Net, C#

CheckboxList required field validation

Today I came across a situation where I need to validate CheckboxList as required field and found below solution:

//Bound list from Database
<asp:CheckBoxList ID="chlZones" runat="server" RepeatColumns="5" 
RepeatDirection="Horizontal" />
//Create Custom validator that will work as required validator. Profile function
<asp:CustomValidator ID="cvalZones" runat="server" 
ClientValidationFunction="ValidateZones" ErrorMessage="!!!" 
Display="Dynamic" />

//Implement Client method
<script>
function ValidateZones(source, args) {
		var chlZones = document.getElementById('');
		var chkLista = chlZones.getElementsByTagName("input");
		for (var i = 0; i < chkLista.length; i++) {
			if (chkLista[i].checked) {
				args.IsValid = true;
				return;
			}
		}
		args.IsValid = false;
	}
</script>
Tagged with: ,
Posted in Asp.Net

Application Lifecycle Management

Today I found very good article for Project Management activity and how you can manage your project in very effective manner. I would like to share and you must see once this article and follow it:

  • Integrated planning
  • Traceability of related artifacts
  • Development intelligence
  • Automation and Collaboration
  • Continuous process improvement

 

http://www.cmcrossroads.com/cm-articles/275-articles/13980-five-imperatives-for-application-lifecycle-management

Tagged with: ,
Posted in Project Management

IE9 Beta download

Today Microsoft announced IE9 beta released and now available for download in different languages. To get more about it find below URL:

http://www.microsoft.com/presspass/presskits/internetexplorer/

Thanks

Tagged with:
Posted in IE
Top Rated

Error: Please make sure the Twitter account is public.

Blog Stats
  • 30,264 hits