Bar Chart random color in asp.Net

Display bars in random colors:

IDictionary<string, int> list= new Dictionary<string, int>();
list.Add(“Val 1″, 90);
list.Add(“Val  2″, 89);
list.Add(“Val 3″, 50);
list.Add(“Val 5″, 87);

chrtBar2.Series["Categories"].XValueMember = “key”;
chrtBar2.Series["Categories"].YValueMembers = “value”;
chrtBar2.ChartAreas["MainChartArea"].AxisX.MajorGrid.Enabled = false;
chrtBar2.ChartAreas["MainChartArea"].AxisX.MajorTickMark.Enabled = true;
chrtBar2.ChartAreas["MainChartArea"].AxisX.MinorGrid.Enabled = false;
chrtBar2.ChartAreas["MainChartArea"].AxisX.MinorTickMark.Enabled = false;
chrtBar2.ChartAreas["MainChartArea"].AxisY.MajorGrid.Enabled = false;
chrtBar2.ChartAreas["MainChartArea"].AxisY.MajorTickMark.Enabled = true;
chrtBar2.ChartAreas["MainChartArea"].AxisY.MinorGrid.Enabled = false;
chrtBar2.ChartAreas["MainChartArea"].AxisY.MinorTickMark.Enabled = false;
chrtBar2.Series["Categories"]["PointWidth"] = “1.0″;
chrtBar2.Series["Categories"].BorderWidth = 1;
chrtBar2 .Series["Categories"].BorderColor = Color.White;
chrtBar2.DataSource = list;
chrtBar2.DataBind();

//Set random color
Random random = new Random();foreach (var item in chrtBar2.Series["Categories"].Points)

{
Color c = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));
item.Color = c;
}

Each time will change the bar colors  when page will refreshed.

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');
            }
        });

});



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>

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>

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>

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>

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

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

Increase website ranking on Google Search

To increase the website ranking, we have to follow the certain rules. Since last few last days I was digging into more to get understand the logic behind the google search engine.

Found the great article which covers all the rules:

http://www.ssw.com.au/SSW/Standards/Rules/RulesToBetterGoogleRankings.aspx#HowGoogleRanksPages

Thanks

JQuery tutorials

Hi Guys, I just want to share good resource for JQuery tutorials for beginner and advanced developers. Please find below link:

http://blog.themeforest.net/tutorials/jquery-for-absolute-beginners-video-series/

Follow

Get every new post delivered to your Inbox.