Friday, May 31, 2013

Can we run asp.net application without WEB.CONFIG file ?

1 comments Posted by Rahul Kharde at 5:16 AM
Yes, we can run an asp.net application without the WEB.CONFIG file.

If we are not setting any configuration in
WEB.CONFIG file then it will take MACHINE.CONFIG file for default configurations. This config file will automatically installed when your application getting executed.

i.e
MACHINE.CONFIG file contains defaults settings for all the asp.net web applications.

Because all the configuration settings will be available under
MACHINE.CONFIG file by default these settings will be applied to all asp.net applications.

Note:
  • Web application run without web.config but the run without debugging mode 
  • In 2005 The VS When we trying to run first time any application the 2005 VS gives us warning that want to run application without web.config file.
  • The MACHINE.CONFIG file will be automatically loaded when .net framework is installed. 
Read More »

Thursday, May 30, 2013

About The X: prefix?

0 comments Posted by Rahul Kharde at 12:05 AM
In the previous root element example, the prefix x: was used to map the XAML namespace http://schemas.microsoft.com/winfx/2006/xaml, which is the dedicated XAML namespace that supports XAML language constructs. This x: prefix is used for mapping this XAML namespace in the templates for projects. The XAML namespace for the XAML language contain several programming constructs that you will use very frequently in your XAML. The following is a listing of the most common x: prefix programming constructs you will use: 

x:Key: Sets a unique key for each resource in a ResourceDictionary (or similar dictionary concepts in other frameworks)

Example
<Grid>
    <Grid.Resources>
        <Style x:Name="StyleName" x:Key="StyleKey" />
    </Grid.Resources>
    <Button Style="{StaticResource StyleKey}" />
</Grid>

x:Class: Specifies the CLR namespace and class name for the class that provides code-behind for a XAML page. You must have such a class tos support code-behind per the WPF programming model, and therefore you almost always see x: mapped, even if there are no resources.

x:Name: Specifies a run-time object name for the instance that exists in run-time code after an object element is processed. In general, you will frequently use a WPF-defined equivalent property for x:Name. Such properties map specifically to a CLR backing property and are thus more convenient for application programming, where you frequently use run time code to find the named elements from initialized XAML. The most common such property is FrameworkElement.Name. You might still use x:Name when the equivalent WPF framework-level Name property is not supported in a particular type. This occurs in certain animation scenarios.

Example
<Button x:Name="okButton">OK</Button>

x:Static: Enables a reference that returns a static value that is not otherwise a XAML-compatible property. 

Example
<SolidColorBrush Color="{x:Static SystemColors.ControlColor}" />

x:Type: Constructs a Type reference based on a type name. This is used to specify attributes that take Type, such as Style.TargetType, although frequently the property has native string-to-Type conversion in such a way that the x:Type markup extension usage is optional.

Example
<Style TargetType="{x:Type Button}">
    ...
</Style>

Reference 


Read More »

Tuesday, May 28, 2013

WPF: TextBlock Vs Label

0 comments Posted by Rahul Kharde at 5:11 AM

Every WPF developer asked himself is why we have Label and TextBlock controls in WPF When it used.
TextBlock and Label both are used to display text.

TextBlock
Label
Textblock inherits from FrameworkElement
Label Inherits from System.Windows.Control
Lightweight
Heavy Weight control
Does not Supports access key
Label supports access key
TextBlock don’t have the IsEnabled Proerty
Label’s IsEnabled property returns false its text color change into gray
Simple control
More complex control
TextBlock does not have link to other controls as Target
It has a Target property

Label has an important focus handling responsibility. Its purpose is to allow you to place a caption with an access key. It has a Target property, which indicates the target of the access key. 

Example

<Label Target="{Binding ElementName=name}">User Name:</Label>
<TextBox x:Name="name" />

When to used label and TextBlock?

When you want to display text by itself use the TextBlock. The benefit is a light, performing way to display text.

When you want to associate text with another control like a TextBox use the Label control. The benefits are access keys and references to target control.


Read More »

Thursday, May 23, 2013

How to check that RadioButtonList has a selected value

0 comments Posted by Rahul Kharde at 5:01 AM
RadioButtonList has two property to find out any item is selected or not.

1) SelectedIndex

2) SelectedItem


HTML

<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Value="0" Selected="True">YES</asp:ListItem>
<asp:ListItem Value="1">NO</asp:ListItem>
</asp:RadioButtonList>

Sometime you need to check to see if a value has been selected before you do anything in coding

CS Code

if (RadioButtonList1.SelectedItem != null)
{
     RadioButtonList1.SelectedItem.Selected = false;
}

Or 

if(RadioButtonList1.SelectedIndex<>-1)
{
     RadioButtonList1.SelectedItem.Selected=false;
}

Read More »
 

Popular Posts

Recent Comments

© 2011. All Rights Reserved | Help to understand .Net | Template by Blogger Widgets

Home | About | Top