Monday, 8 June 2015

Convert wsdl file to class file

Steps to convert wsdl file to class file

  • Find the Web Services Description Language Tool (WSDL.exe). This file comes with .net framework. So if you already install .net Framework you will get this exe in you machine. Here is a probable location of wsdl.exe "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\x64"
  • Go to the exe file location and open command prompt and type below command. "wsdl /out:myProxyClass.cs http://soap.proofhq.com/15_6_0/soap.wsdl". Like wsdl {output class file} {wsdl file path}

Tuesday, 19 May 2015

Firefox scrollbar issue based on height

There is a weird problem in firefox regarding scrollbar. If a div heights is 30px or less, then overflow-y  style will not work any more in firefox.
So the resolution is increase the div height, say for example 40px. It will work properly.

Monday, 22 July 2013

CSS3 Pseudo Classes: first-of-type, last-child, first-child and last-of-type

  • first-of-type: It selects first element of same type. This is similar to first-child, which was introduced in CSS2. In practice, however, they are as different as nth-child and nth-of-type. 
            <div>
                <h2>Wuthering Heights</h2>
                <p>I have just returned...</p>
                <p>This is certainly...</p>
                <p>In all England...</p>
                <h3>By Emily Bronte</h3>
            </div>
       p:first-of-type { font-style: italic; }
       Result: I have just returned...
  • first-child: It selects the first element of the parent. If i use above div element example.
      p:first-child {text-decoration: underline;}
      Result: no element will be selected.
      if i remove <h2>Wuthering Heights</h2> element then it will select <p>I have just returned...</p>

     last-of-type &  last-child will work in the reverse way. It will select last element of same type and last element of the siblings accordingly.

CSS3 pseudo classes: Difference between only-child and only-of-type

  • Only-child: Select elements of the document tree if parent have have only one child means there is no siblings.
        <div>          
                <p>I have just returned.</p>               
        </div>
        p:only-child { text-decoration: underline; }

  • Only-of-type: Selects elements of the document tree if parent have no siblings of same type.
            <div>
                <h2>Wuthering Heights</h2>                
                <p>In all England...</p>
                <h3>By Emily Bronte</h3>
            </div>
           p:only-of-type { font-style: italic; }

Thursday, 18 July 2013

Retrieve App pool password.

If you forget password of app pool, it is very difficult to retrieve password. There is a simple command for this. Just go to you command prompt and type below command:

C:\Windows\System32\inetsrv\appcmd.exe list apppool -config

It will return a XML file.

Monday, 28 November 2011


Set "!important" style by JavaScript

It is very easy to set style in any DOM element by Javascript like:

var target = document.getElementById('MyDiv');
target .style.marginleft ="100px";

But if you want to add "!important" like this -

target .style.marginleft ="100px !important";
this will not work.

Use this code to get it done.
target.setAttribute('style', 'margin-left:200px !important');

Sunday, 25 July 2010

Tab Control in Silverlight

Silverlight tab control is very easy to use. Drag and drop the control on .xaml page. You can change various property of tab control like height, width, background etc. It has various events also. There is place holder around the tab control. To make it void make the border thickness property zero. It took bit time to fix this problem. Tab control contain tab item. Numbers of tab items are added as it is require. 
Tab Items may contain border for beautification. One important thing we need in page that is scroll viewer when page become large. We can add scroll viewer within tab item. 

<controls:TabControl x:Name="tbBuilder" Height="auto" Width="auto" BorderThickness="0"
                  Background="Transparent" SelectionChanged="tbBuilder_SelectionChanged" Margin="0,9,0,0">

                    <!--General-->
                    <controls:TabItem x:Name="tbItemBuilderInformation" Header="Information" Margin="5,0,0,0">
                            <Border  BorderThickness="1,1,1,1" BorderBrush="Black" Height="auto" Width="auto" Background="White"  VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                                <StackPanel x:Name="stkPnlBuilderInformation" Height="auto" Width="auto"></StackPanel>                       
                            </Border>
                    </controls:TabItem>
               
                <!--Logo-->
                    <controls:TabItem x:Name="tbItemBuilderLogo" Header="Logo and Video">
                        <Border  BorderThickness="1,1,1,1" BorderBrush="Black" Height="auto" Width="auto" Background="White"  VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                            <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"  BorderThickness="0" Margin="0" Height="auto" Style="{StaticResource ScrollViewerStyle1}" >
                                <StackPanel x:Name="stkPnlBuilderLogo" Height="auto" Width="auto"></StackPanel>
                            </ScrollViewer>
                        </Border>
                    </controls:TabItem>
</controls:TabControl>

In the above example we used stackpanel inside tab item. Now we can load xaml page in stack panel. There is various ways to code with tab control. 

Wednesday, 21 July 2010

Add CSS in ASP.Net class file

Normally we add CSS in .aspx file. It is pretty easy to add CSS in .aspx file just drag CSS file and drop it to .ascx header. Automatically a link will create. Sometimes we need to add CSS in class file. In page load event we can add CSS by adding following code.

HtmlLink link = new HtmlLink();
link.ID = ID;
link.Attributes.Add("type", "text/css");
link.Attributes.Add("rel", "stylesheet");
link.Href = "/" + SiteSettingsConfiguration.GlobalPathPrefix + "Global/CommonSite/Css/GeneralStyles.css";
Page.Header.Controls.Add(link);

Sunday, 11 July 2010

Add/Remove value in cookie

To set value copy following method:
        public static void SetCookie(string key, string value)
        {
            string oldCookie = HtmlPage.Document.GetProperty("cookie") as String;
            DateTime expiration = DateTime.UtcNow + TimeSpan.FromDays(2000);
            string cookie = String.Format("{0}={1};expires={2}", key, value, expiration.ToString("R"));
            HtmlPage.Document.SetProperty("cookie", cookie);
        }

To get cookie value copy below method. 
        public static string GetCookie(string key)
        {
            try
            {
                string[] cookies = HtmlPage.Document.Cookies.Split(';');
                //key += '=';
                foreach (string cookie in cookies)
                {
                    string cookieStr = cookie.Trim();
                    string[] vals = cookieStr.Split('=');
                    if (vals.Length >= 2)
                    {
                        if (vals[0].Equals(key, StringComparison.OrdinalIgnoreCase))
                        {
                            return vals[1];
                        }
                    }

                }
            }
            catch
            {
               
               
            }

            return null;
        }

Delete value from cookie add below method
   public static void DeleteCookie(string key)
        {
            string oldCookie = HtmlPage.Document.GetProperty("cookie") as String;
            DateTime expiration = DateTime.UtcNow - TimeSpan.FromDays(1);
            string cookie = String.Format("{0}=;expires={1}", key, expiration.ToString("R"));
            HtmlPage.Document.SetProperty("cookie", cookie);
        }

Wednesday, 30 June 2010

Change Silverlight Border Background

Silverlighet Border is a strong control. It is widely used. To make Border stylish it has various properties to design accordingly.

<Border x:Name="bdrBody" Margin="12,71,20,16"  Visibility="Visible" CornerRadius="5,5,10,10" BorderThickness="4,1,1,1" BorderBrush="Blue" Padding="5,5,5,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <Border.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="White" />
                    <GradientStop Color="Black" Offset="1"/>
                </LinearGradientBrush>
            </Border.Background>
            <Grid x:Name="grdMain" Height="Auto" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</Border>
Here is an example of Border.
CornerRadius – Make border corner rounded.
BorderThickness – Make border side thickness bold or light.
BorderBrush – Change border rounded color.
Margin – To fix position of border.
We can give a button look and feel of a border by changing LinearGradientBrush property of Border.Background. Expression blend is the best way of changing border style. Manually changing GradientStop color and Offset value we can make border attractive. It can be use as container of another pages, here grdMain is used as a container.

Tuesday, 29 June 2010

Expanded TreeViewItem Style in Silverlight TreeView

By default TreeView item child is not expanded. It remains collapsed. To make it expanded we have to apply following style in .xaml page where TreeViwe controls are used.


<controls:TreeView x:Name="trvLeftMenu"  BorderThickness="0,1,0,0" Margin="0" Width="auto"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                                       ItemContainerStyle="{StaticResource expandedTreeViewItemStyle}">
</controls:TreeView>

ItemContainerStyle – is the expand property.
expandedTreeViewItemStyle – is the name of style.

Below is the calling style.

<UserControl.Resources>
<Style x:Key="expandedTreeViewItemStyle" TargetType="controls:TreeViewItem">
            <Setter Property="IsExpanded" Value="True" />
</Style>
</UserControl.Resources>


Treeview control of Silverlight

Using TreeView is pretty simple to use. It takes TreeViewItem as its child. Depending on child item we can feed TreeViewItem  to TreeView. If we need inner child we will feed TreeViewItem  to TreeViewItem . Like –

<controls:TreeView x:Name="trvLeftMenu"  BorderThickness="0,1,0,0" Margin="0" Width="auto"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> </controls:TreeView>

trvLeftMenu.Items.Clear();
for (int i = 0; i < builderList.Count; i++)
{
TreeViewItem item1 = new TreeViewItem();
for (int j = 0; j < builderList[i].SalesOffices.Count; j++)
{
      TreeViewItem soItem = new TreeViewItem();
      item1.Items.Add(soItem);
}
trvLeftMenu.Items.Add(item1);
}

Through this way we can build up a tree. Child item and inner child item binding. There are various properties of TreeView and TreeViewItem. Header property hold header name. We can bind image with text in stackpanel then bind that stackpanel as a Header of TreeView.
mhItem.Selected += new RoutedEventHandler(modelHomeItem_Selected);
If we apply Selected event it will execute when we click on items on run time.

Sunday, 27 June 2010

WCF Service method async call from Silverlight project.

There are three steps to call a WCF service from silverlight project.

1. Create WCF service client instance.

PCSalesOfficeServiceClient _PCSalesOfficeServiceClient = new PCSalesOfficeServiceClient();

2. To catch asynchronous call response we have to use delegates. For every method of WCF service there is a completed event and an asynchronous method. So initially we will assign completed event of any WCF methods.

_PCSalesOfficeServiceClient.SaveSalesOfficeCompleted += new EventHandler<SaveSalesOfficeCompletedEventArgs>(_PCSalesOfficeServiceClient_SaveSalesOfficeCompleted);

3. Finally we will make call where it is necessary. For every call there is a completed event, no matter what is return type of calling method. To catch completed event we have to follow step two.

_PCSalesOfficeServiceClient.SaveSalesOfficeAsync(_SalesOffice);


Tuesday, 22 June 2010

Silverlight Page Container

this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;
During project creation those methods automatically create. Application_Startup method invokes during initiation and Application_Exit invoke during closing of project. Application_Startup method load MainPage instance by default.

this.RootVisual = new MainPage();

Main Page is the container of .xaml pages. Now we can create layout of our project according to our requirements. Every .xaml page create <Grid/> control by default. To display or show silverlight pages we use grid control. It acts like a container for silverlight pages. But at a time it can hold one page. To load new page previous page has to remove.

AdminLandingLeftMenu adminLandingLeftMenu = new AdminLandingLeftMenu();
grdMenue.Children.Clear();
grdMenue.Children.Add(adminLandingLeftMenu);


grdMenue – Is the grid name.
adminLandingLeftMenu – Is the instance of a silverlight page.

First we clear the children of grid(if any exist) then add new page instance to display.

Friday, 11 June 2010

Data Bind in Silverlight DataGrid


To show data in datagrid view, we need to assign a list to the itemsource of datagrid.
dgSalesOfficeLiveAgent.ItemsSource = e.Result;
e.Result – is the list of data.
Above is enough for .cs file. But in .xaml we should configure the datagrid. There are lots of property of datagrid. According to our requirement it is configurable.  Most important things are column configuration. Silverlight datagrid is very powerful. A column can be editable. It may contain multiple controls like TextBlock, Image, TextBox etc. We can combine various controls simultaneous. Basic structure of a datagrid –

There are three different type of column declare above.
1. First one simply text binding. It is highly used to bind normal text. Example - How to use it.
Header – is the name to be appears on column head.
FirstName – is the property name of list which is assigned to the datagrid itemsourch.
2. Second one is used when we want to modify our text like bold or coloring etc we have to use control like <TextBlock/>. We may use <Image/> tag to store image. Example –
In <Image/> tag there are various property has set. We can add event like OnMouseleftbuttonUp to fire some event on mouse click.
3. Third Option is used when we want to add multiple controls within a column.
To manipulate datagrid from .cs file we can use LoddingRow event of datagrid. To search control of datagrid we have to search that control by it name –
FrameworkElement eleBargainingRoomButton = dgModelHome.Columns[3].GetCellContent(e.Row);
                Button btnBargainingRoomButton = eleBargainingRoomButton.FindName("btnBargainingRoom") as Button;
btnBargainingRoom – Is the Button control name inside datagrid.
Columns[3] – Button is in fourth column.

Saturday, 5 June 2010

File upload from silverlight project to file server

1. Take a Generic Handler file (.ashx) in web project. It’s automatically generated following method.

public void ProcessRequest(HttpContext context)
{
}

Context hold full url. So when we send a request to the handler this method automatically invoked. Now we can extract query string from url.

string action = context.Request.QueryString["action"].ToString();
Where action is the query string name.

2. From silverlight project prepare url and stream data (file) to send into the file server. OpenFileDialog is the class through which we can bind file data to Stream like.

openFileDialog.File.OpenRead();

3. Pass url and data stream by calling UploadFile(url, streamData). Below are the methods. This two methods duty are to send data of the respected url (our handler class).


In the handler class two types of operations take place. One is save data and one is retrieve data.

1. To save data, copy it inside ProcessRequest() method.

BuilderLandingPageImageSave – is the query string, checking the exact query string name of action.

Path – is the location where the file is going to save. Here we saved path name in web.confg file. So we are just calling it.

Filename – is the name of file in which name it is going to save. We can pass the file name from silverlight project by binding query string like action. Below is the WriteFileToDisk() method.


2. To retrive data from ProcessRequest() method

BuilderVideoTutorialLoading - is the query string name.

Path - file location.

ReadMediaFile() method is below.