Tuesday, April 28, 2009

Storing Values into Registry in SET UP Project in WINDOWS

Hi All,

This post discusses about entering values into the Registry while you are making Set Up Project for Windows Applications.

Go to File New Project->Other Project Types->SetUpProject.

After the Solution is added ,right click on the Solution and go to View User Interface.
After then Right click on START -> Add Dialog->Select TextBox(A).

There are Four text Boxes by Default,you can make them invisible false.
Lets take for Textbox1 which is named as EDIT1A.Enter BodyText,Banner Text and Edit1Label Text as desired.
now right click again on Solution->view Registry->HKEY_CURRENT_USER->Software
Add key Named as anyone say Alerts.

Right click on Alerts->New String Value as EMAIL

Now right click on EMAIL-> Set the Value of EMAIL as [EDIT1A]. The point to be noted here is the Value [EDIT1A]. The value has to be kept in Square Brackets.


After running the set up, the registry value will be entered in System Registry under HKEY_CURRENT_USER->Software->Alerts.

Thanks,
Nitin Sharma

Monday, April 20, 2009

Querying Web.SiteMap using LINQ

Querying Web.SiteMap using LINQ

The sample web.sitemap used in this article is shown below:

xml version="1.0" encoding="utf-8"?>

<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">

<siteMapNode title="My Favorites">

<siteMapNode title="Favorite Sites">

<siteMapNode title="ASP.NET Home" url="http://www.asp.net" />

<siteMapNode title="ASP.NET Articles" url="http://www.dotnetcurry.com"/>

<siteMapNode title="Windows Client" url="http://www.windowsclient.net" />

<siteMapNode title="Silverlight" url="http://silverlight.net" />

siteMapNode>

<siteMapNode title="Favorite Blogs">

<siteMapNode title="ScottGu Blog" url="http://weblogs.asp.net/scottgu"/>

<siteMapNode title="Technology Blog" url="http://www.devcurry.com" />

<siteMapNode title="SQL Blog" url="http://www.sqlservercurry.com" />

<siteMapNode title="Food Lovers" url="http://foodatarian.com" />

siteMapNode>

<siteMapNode title="Favorite Social Sites">

<siteMapNode title="Twitter" url="http://twitter.com/"/>

<siteMapNode title="FaceBook" url="http://www.facebook.com" />

<siteMapNode title="LinkedIn" url="http://www.linkedin.com" />

<siteMapNode title="Orkut" url="http://www.orkut.com" />

siteMapNode>

siteMapNode>

siteMap>

The Data Source for above web.sitemap is Bulleted List.

<asp:BulletedList ID="linkList" DisplayMode="HyperLink" runat="server">

asp:BulletedList>

List all Url’s in the SiteMap using LINQ

XElement xelement = XElement.Load(Server.MapPath("~/web.sitemap"));

var urlList = xelement.Descendants().Attributes()

.Where(x => x.Name == "url")

.Select(x => x.Value);

foreach (string s in urlList)

{

linkList.Items.Add(s);

}

List Url’s and Title in the SiteMap using LINQ

XElement xelement1 = XElement.Load(Server.MapPath("~/web.sitemap"));

var urlDescList = xelement1.Descendants()

.Where(element => element.LastAttribute.Name.LocalName.Contains("url"))

.Select(nd => new

{

title = nd.Attribute("title")

.Value,

url = nd.Attribute("url")

.Value

});

foreach (var v in urlDescList)

{

ListItem li = new ListItem(v.title, v.url);

linkList.Items.Add(li);

}

List Url’s and Title of a particular node of the SiteMap using LINQ

XElement xelement2 = XElement.Load(Server.MapPath("~/web.sitemap"));

var urlDescList1 = xelement2.Descendants()

// Select node with 'Favorite Social Sites'

.Where(sel => (string)sel.Attribute("title") == "Favorite Social Sites")

.SelectMany(sel => sel.Elements())

.Select(nd => new

{

title = nd.Attribute("title").Value,

url = nd.Attribute("url").Value

});

foreach (var s in urlDescList1)

{

ListItem li = new ListItem(s.title, s.url);

linkList.Items.Add(li);

}

Count the number of nodes in each parent element of SiteMap using LINQ

XElement xelement3 = XElement.Load(Server.MapPath("~/web.sitemap"));

var t = xelement3.Descendants()

.Where(x => x.LastAttribute.Name.LocalName != "url")

.Select(ele => new

{

Name = (string)ele.Attribute("title"),

Count = ele.Elements().Count()

});

Source: http://www.dotnetcurry.com/ShowArticle.aspx?ID=284&AspxAutoDetectCookieSupport=1

Thanks,

Nitin Sharma

Wednesday, April 8, 2009

JQuery Examples of Plugins

How to Load one Page into another.
Example on AjaxJQ01.aspx:

$(document).ready(function() {
$('#Panel1').load('AjaxJQ1.aspx');

});



How to make Controls Resizable ?
The example below Resizes TextBox,Button,DIV,Image.
Just add the UI.Resizable.js plugin ,ui.core.js along with the latest Jquery reference. and add below code and see the magic of Jquery:


$(document).ready(function() {
$("#TextBox1").resizable();
$("#Button1").resizable();
$("#resizable").resizable();
$("#Image1").resizable();

});


Where #TextBox1,#Button1,#Image1 are the ID of respective asp.net controls where as #resizeable is the ID of DIV placed inside the page.


How to Use Drag and Drop Plugin in General.?

Add the Draggable.js and Droppable.js and ui.core.js Plugin.And add the following Code:


$(document).ready(function() {


//$("#divDrag").draggable({ helper: 'clone' });
$("#divDrag").draggable();

$("#divDrop").droppable({

accept: "#divDrag",

activeClass: 'droppable-active',

hoverClass: 'droppable-hover',

drop: function(ev, ui) {

$(this).append("
Dropped :)");


var theId = $(this).attr("id");

// alert(theId);

//Do your AJAX stuff in here.

}

});

On the Page :

div id='divDrop'
Drop Here.
div


div id='divDrag'
Drag Me.div



Just Delve into JQuery ...you'll fall in love with it.......

Thanks,
Nitin Sharma

Moon Driving Car @ Shipra Mall



Part I







Part II





Part III


Monday, March 9, 2009

DropDownList inside Gridview

Hi All,

It is very common to have child controls inside the Gridview.Among them Drop down List is very common.Drop down list inside the gridview and handling their selected index changed event becomes inevitable.

We know that Drop Down list does not Support Command Name property so we cant handle the event in the Row Command event.

Here is the solution of it...which is used very very commonly...

protected void dropdownlist1_SelectedIndexChanged(object sender, EventArgs e) {

// get reference to the row

GridViewRow gvrow = (GridViewRow)(((Control)sender).NamingContainer);

// Get the reference of this DropDownlist

DropDownList ddl1= (DropDownList) gvrow.FindControl("dropdownlist1");

// Get the reference of other DropDownlist in the same row.

DropDownList ddl2= (DropDownList) gvrow.FindControl("dropdownlist2");

}


Thanks,

Nitin Sharma