Tuesday, October 4, 2011

Debugging silverlight application using Debugger.

Today I Just working with Silverlight application I can’t able to debug Silverlight application through debugger but it is working fine with web project.I had written about debug asp.net Application using debuger before one year ago.we are easily attache bebugger using aspnet_we.exe. This debugger working perfectly with asp.net application.I thought  it should be work for silverlight application also I make digging on net  find solution for that we have to attach another process like Iexplore.Exe which type is "Silverlight, 86" see below image you get complete idea about  how to attach two process.
 Debugger(1)


now you are able to debug your silverlight application using debugger. this post me be useful to you.Thanks for reading stayed turned for more.

Thank You
Kirti Darji








Saturday, September 24, 2011

Maintain browser history using Ajax parent child tab container control

I am working on one project in on which  I have to maintain browser history for Ajax tab container control.when user click on tab history should be saved and it should be display on browser back button click event. I got a one blog post from my friend jalpesh  I got a basic idea about how we done. My requirement is something different like one page there is a tab container control are putted with three different type of tab like tab1,tab2 and tab3 now in tab1 content I want to load another user control which have four different type of tab like childtab1,childtab2,childtab3 and childtab4 I want to maintain Ajax tab container browser history on browser back button for child and parent tab so I make it possible using following way.
Historymain
Put script manager on Parent page like
<asp:ScriptManager id="scriptManager" runat="server" EnableHistory="true" OnNavigate="scriptManager_Navigate">   </asp:ScriptManager>
Now parent page contain scriptmanager as well as tabcontainer control.and child page(User Control) contain tabcontainer control.now one thing you notice there we use one script manager for both page so how can we get script manager on child page(User Control).To achieve this we have to define one property for script manager on child page(User Control) and add  Event handler for onvavigaet event of script manager when initializecomponent of child page(user control).following is code for that in Child page(user control)
private ScriptManager scriptManager { get { return AjaxControlToolkit.ToolkitScriptManager.GetCurrent(this.Page); } } 
Add event handler for onnavigate vent for scriptmanager using
override protected void OnInit(EventArgs e)
       {
           InitializeComponent();
       }
private void InitializeComponent()
       {
           scriptManager.Navigate += new EventHandler<HistoryEventArgs>(scriptManager_Navigate);
       } 
now on OnActiveTabChanged Event of ajaxtabcontainer of parent page we make a code for save history point in collection using addhistorypoint method of scriptmanager. we have save history point for both pages mean Parent page which contain Tab1,Tab2 and Tab3 and Child page(User Control) means its contain Child1,Child2,Child3 and Child4 etc. and one child page we can say one user control is there on Page. So we can achieve out goal for saving history by save history point value with tabcontainer name. so for that we make below code on ActiveTabChanged event of tabcontainer on parent page as well as Child Page(User Control)
Parent Page
protected void ajxTab_ActiveTabChanged(object sender, EventArgs e)
        {
           if(scriptManager.IsInAsyncPostBack && !scriptManager.IsNavigating)
           {
               scriptManager.AddHistoryPoint("historyPoint", string.Format("{0}#{1}","ajxTab", ajxTab.ActiveTabIndex.ToString()),ajxTab.ActiveTab.HeaderText);
           }
        }
Child Page(User Control)
protected void subajxTab_ActiveTabChanged(object sender, EventArgs e)
        {
            if (scriptManager.IsInAsyncPostBack && !scriptManager.IsNavigating)
            {
                scriptManager.AddHistoryPoint("historyPoint",string.Format("{0}#{1}","subajxTab",subajxTab.ActiveTabIndex.ToString()), subajxTab.ActiveTab.HeaderText);
            }
        } 
when browser back button is clicked scriptmanager  Navigate event is fire so we can check on scriptmanager navigate event if historypoint is not null then set activeTabIndex for that tab.this scriptmanager navigate event is implemented on both page parent and child page(User Control) if parent page ajax tab name we found after splitting historypoint value then we set parent page tabcontainer control activeTabIndex else child page (User Control)activeTabIndex index following is code  is for scriptmanager Navigate event for both page.
Parent Page
protected void scriptManager_Navigate(object sender, HistoryEventArgs e)
{
string state = e.State["historyPoint"];
if (state != null)
{
string[] arrstring = state.Split('#');
if (arrstring[0] == "ajxTab")
ajxTab.ActiveTabIndex = Convert.ToInt32(arrstring[1]);
}
else

ajxTab.ActiveTabIndex = 0;
}

Child Page
void scriptManager_Navigate(object sender, HistoryEventArgs e)
       {
           string state = e.State["historyPoint"];
           if (state != null)
           {
               string[] arrstring = state.Split('#');
               if (arrstring[0] == "subajxTab")
                   subajxTab.ActiveTabIndex = Convert.ToInt32(arrstring[1]);
           }
           else
               subajxTab.ActiveTabIndex = 0; 

       }
I tried my best to explain this in detail if any one could to  get some point please feel free to contact me by putting comment I will try my best to explain as soon as possible.Thank You for reading. Stay Turned for more.

Thursday, August 18, 2011

How to convert a Number to words

This article I am going to discuss function which convert numeric value to word  for that we create one web page which return convert number to word.
To achieve this I  create one simple webpage which have one textbox and one button when click on button number is converted to text and display in label see below image.


ConvertNumber
I have create on class which convert given number to text

static class NumberToWord
{
private static string[] _ones =
{
"zero",
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine"
};

private static string[] _teens =
{
"ten",
"eleven",
"twelve",
"thirteen",
"fourteen",
"fifteen",
"sixteen",
"seventeen",
"eighteen",
"nineteen"
};

private static string[] _tens =
{
"",
"ten",
"twenty",
"thirty",
"forty",
"fifty",
"sixty",
"seventy",
"eighty",
"ninety"
};

// US Nnumbering:
private static string[] _thousands =
{
"",
"thousand",
"million",
"billion",
"trillion",
"quadrillion"
};

/// 
/// Converts a numeric value to words suitable for the portion of
/// a check that writes out the amount.
/// 
/// Value to be converted
/// 
public static string Convert(decimal value)
{
string digits, temp;
bool showThousands = false;
bool allZeros = true;
StringBuilder builder = new StringBuilder();
// Convert integer portion of value to string
digits = ((long)value).ToString();
// Traverse characters in reverse order
for (int i = digits.Length - 1; i >= 0; i--)
{
int ndigit = (int)(digits[i] - '0');
int column = (digits.Length - (i + 1));

// Determine if ones, tens, or hundreds column
switch (column % 3)
{
case 0:        // Ones position
showThousands = true;
if (i == 0)
{
// First digit in number (last in loop)
temp = String.Format("{0} ", _ones[ndigit]);
}
else if (digits[i - 1] == '1')
{
// This digit is part of "teen" value
temp = String.Format("{0} ", _teens[ndigit]);
// Skip tens position
i--;
}
else if (ndigit != 0)
{
// Any non-zero digit
temp = String.Format("{0} ", _ones[ndigit]);
}
else
{
// This digit is zero. If digit in tens and hundreds
// column are also zero, don't show "thousands"
temp = String.Empty;
// Test for non-zero digit in this grouping
if (digits[i - 1] != '0' || (i > 1 && digits[i - 2] != '0'))
showThousands = true;
else
showThousands = false;
}

// Show "thousands" if non-zero in grouping
if (showThousands)
{
if (column > 0)
{
temp = String.Format("{0}{1}{2}",
temp,
_thousands[column / 3],
//allZeros ? " " : ", ");
allZeros ? " " : " ");
}
// Indicate non-zero digit encountered
allZeros = false;
}
builder.Insert(0, temp);
break;

case 1:        // Tens column
if (ndigit > 0)
{
temp = String.Format("{0}{1}",
_tens[ndigit],
(digits[i + 1] != '0') ? "-" : " ");
builder.Insert(0, temp);
}
break;

case 2:        // Hundreds column
if (ndigit > 0)
{
temp = String.Format("{0} hundred ", _ones[ndigit]);
builder.Insert(0, temp);
}
break;
}
}

// Append fractional portion/cents
builder.AppendFormat(" DOLLARS and {0:00} / 100", (value - (long)value) * 100);

// Capitalize first letter
return String.Format("{0}{1}",
Char.ToUpper(builder[0]),
builder.ToString(1, builder.Length - 1));
}
}

I made following code on button click event
protected void btnconvert_Click(object sender, EventArgs e)
{
decimal number;
if(!string.IsNullOrEmpty(txtnumber.Text)&& decimal.TryParse(txtnumber.Text.Trim(),out number))
{
lblText.Text=NumberToWord.Convert(number);
}

}

it covert given number to word. This may be useful for you. Stay turned for more.
Thanks for reading. Happy coding!!

Wednesday, August 3, 2011

New Option dialog box enhancement in Visual studio 2010

I was working on start up page for visual studio 2010 at that time I have been notice one enhancement done in visual studio 2010 IDE with tool--> options dialog box.when we open option dialog box  there is new Show all settings checkbox is show. It is for display all setting or not by default this checkbox is not checked so it is shown with minimum options so it is load fast.see below figure
optionlesss

after check Show all settings checkbox it load all setting  see below figure
OptionAll
This information will add +1 in new visual studio 2010 IDE enhancement. Thanks for reading.
Kirti Darji

Sunday, July 31, 2011

Set Start Up page on Visual studio IDE

Today I want to work on one project but unfortunately I miss the location where it actually save.so I though when I open visual studio I can find it from Visual studio IDE start page recent opened project list but unfortunately something is change so start page is not loading when I open visual studio IDE it display like

 sratpagemsdn

I think for while there should be a setting in visual studio IDE.I start  digging  on net for few minutes and I found there is a setting in Visual studio menu Tools—>options where we can  configure start up page with following six option  provided by Visual studio IDE

  1. Open Home Page
  2. Load last loaded solutions
  3. Show open project dialog box
  4. show new project dialog box
  5. show empty environment
  6. show start page

Options

In above figure you can see a setting like show start up page option. I configure this option for show start up page with recent project list.now I reopen my visual studio IDE and I can able to see visual studio IDE with start up page like

Startpage

There is another option is also for see recent opened  project list like like File—>Recent Projects and Solutions

that’s done from my side.It may helpful to you.Thanks for reading happy coding!!

Thank You

Kirti Darji

Friday, July 8, 2011

page life cycle of master page with content page

Generally one question is faced by very developer what is asp.net page life cycle every body know very well like sequence of asp.net page event like

  1. page_init
  2. Page_load
  3. Page_render
  4. Page_unload

it is fine for standalone pages but if a page have master page then what the page life cycle? confuse!!!

Below is the sequence of event of page events which contain master page  with chronological order.

  1. Master page (Page_Init) event
  2. Content page (Page_Init) event
  3. Content page (Page_Load) event
  4. Master page (Page_Load) event
  5. Content page (Page_Prerender) event
  6. Master page (Page_Prerender) event
  7. Content page (Page_Prerendercomplete) event
  8. Master page (Page_Prerendercomplete) event

Remember one thing  page life cycle of page contain master page all event fire like first master page event then content page event but in case of page load event first content page load event fire then master page event fire. so that’s all from my side

I think It may help you, Happy coding, stay turned for more…

Thank You

Kirti M.Darji

Sunday, February 20, 2011

SessionState attribute is new feature in MVC 3.0

one of new feature [SessionState] attribute is in MVC 3.0. that can be use for controller Sassion state  on ,off or make it read only by using SessionStateBehavior Enum with following choice.

Default - The default ASP.NET logic is used to determine the session state behavior for the request. The default logic looks for the existence of marker session state interfaces on the IHttpHandler.
Required - Full read-write session state behavior is enabled for the request. This setting overrides whatever session behavior would have been determined by inspecting the handler for the request.
ReadOnly - Read-only session state is enabled for the request. This means that session state cannot be updated. This setting overrides whatever session state behavior would have been determined by inspecting the handler for the request.
Disabled - Session state is not enabled for processing the request. This setting overrides whatever session behavior would have been determined by inspecting the handler for the request.

Read more

Thank for Reading,

Kirti M.Darji

Sunday, January 30, 2011

what are new features in Visual Studio 2012

The Microsoft working on new version of the Visual Studio. The next release will be Visual studio 2012. this is new feature will be available on visual studio 2012
1.Code window resize
2.Edit code while it execute
3.Automatically add semicolons.
4.Advance copy and pasting code
5.Add reference dial

Read More...

Thank’s for Reading

Kirti M.Darji