RSS

Author Archives: Azhar Saiyed

About Azhar Saiyed

Microsoft Certified Professional

Satellite Assemblies

What Is a Satellite Assembly? A definition from MSDN says something like this: “A .NET Framework assembly containing resources specific to a given language. Using satellite assemblies, you can place the resources for different languages in different assemblies, and the correct assembly is loaded into memory only if the user elects to view the application in that language.”

Creating a Satellite Assembly

  1. Create a folder with a specific culture name (for example, en-IN) in the application’s bin\debug folder.
  2. Create a .resx file in that folder. Place all translated strings into it.
  3. Create a .resources file by using the following command from the .NET command prompt. (localizationsample is the name of the application namespace. If your application uses a nested namespace structure like App.MyApp.Name.MyName as the type of namespace, just use the uppermost namespace for creating resources files—MyApp.)
    resgen Strings.en-IN.resx LocalizationSample.
       Strings.en-IN.resources
    al /embed:LocalizationSample.Strings.en-IN.resources
       /out:LocalizationSample.resources.dll /c:en-IN

    The above step will create two files, LocalizationSample.Strings.en-US.resources and LocalizationSample.resources.dll. Here, LocalizationSample is the name space of the application.

  4. In the code, find the user’s language; for example, en-IN. This is culture specific.
  5. Give the assembly name as the name of [test].resx file.

How to use Satelite assembly ??

Thread.CurrentThread.CurrentCulture =   CultureInfo.CreateSpecificCulture(MyCult);
Thread.CurrentThread.CurrentUICulture =   new CultureInfo(MyCult);
ResourceManager resMgr =   new ResourceManager(typeof(Form1).Namespace + “.” +
assemblyName, this.GetType().Assembly);

For more please visit http://www.codeguru.com/csharp/.net/net_general/tipstricks/article.php/c11367

btnSubmit.Text = resMgr.GetString(“Click”);

 

Thanks & Regards

Azhar Saiyed

pirimamshahbawa.org/

 

 
Leave a comment

Posted by on March 15, 2011 in Uncategorized

 

Difference Between GridView,DataList and Repeater Control

The GridView Web control provides the greatest feature set of the Rpeater control , with its ability to allow the end-user to sort, page, and edit its data. The GridView is also the simplest data Web control to get started with, as using it requires nothing more than adding a GridView to the Web page and writing a few lines of code. The ease of use and impressive features comes at a cost, though, namely that of performance: the GridView is the least efficient of the Repeater control, especially when placed within a Web form.

The DataList provides more control over the look and feel of the displayed data than the DataGrid with its templates. Using templates, however, typically requires more development time than using the DataGrid’s column types. The DataList also supports inline editing of data, but requires a bit more work to implement than the DataGrid. Unfortunately, providing paging and sorting support in the DataList is not a trivial exercise. Making up for these lacking built-in features, the DataList offers better performance over the DataGrid.

Repeater control allows for complete and total control of the rendered HTML markup. With the Repeater, the only HTML emitted are the values of the databinding statements in the templates along with the HTML markup specified in the templates—no “extra” HTML is emitted, as with the GridView. By requiring the developer to specify the complete generated HTML markup, the Repeater often requires the longest development time. Furthermore, the Repeater does not offer built-in editing, sorting, or paging support. However, the Repeater does boast the best performance of the three data Web controls. Its performance is comparable to the DataList’s, but noticeably better than the GridView’s.

 
Leave a comment

Posted by on March 11, 2011 in Uncategorized

 

Reflection in .Net

Reflection

All .NET assemblies have metadata information stored about the types defined in modules. This
metadata information can be accessed by mechanism called as “Reflection”.System. Reflection
can be used to browse through the metadata information.
Using reflection you can also dynamically invoke methods using System.Type.Invokemember.
Below is sample source code 

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Pobjtype As Type
        Dim PobjObject As Object
        Dim PobjButtons As New Windows.Forms.Button()
        Pobjtype = PobjButtons.GetType()
        For Each PobjObject In Pobjtype.GetMembers
            LstDisplay.Items.Add(PobjObject.ToString())
        Next
    End Sub
End Class

Sample source code uses reflection to browse through “Button” class of “Windows.Forms”. If
you compile and run the program following is output as shown in “Sample Reflection Display”.
Using reflection you can also dynamically invoke a method using “System.Type.InvokeMember”.

 
Leave a comment

Posted by on March 11, 2011 in Uncategorized

 

UDF VS Strore Procedure

Function Stored Procedure
1. UDF are simpler to invoke than Stored Procedures from inside another SQL statement. 1. They are Complex to Invoke.
2. Function return type could be scalar or table or table values(SQL Server). 2. It returns always integer value by default zero.
3. The User Defined Function must be prefaced with the owner name. 3.DBO in this case. Not mandatory.
4. A UDF is always used to return a value or a table object. 4. You can also get values back from a stored procedure by the return code (integer only) or an output parameter.
5. Functions are not precompiled. 5. It is pre compiled execution plan.
6. Function returns only one value at a time. 6. It returns more than one value at a time.
7. We can call the functions in SQL statements (select max(sal) from emp). 7.We cannot call Stored Procedures in SQL Statements.
8. Function parameters are always IN, no OUT is possible. Output parameters must be returned as return values. 8.Stored procedures can have input and output parameters.
 
Leave a comment

Posted by on March 11, 2011 in Uncategorized

 

Event bubbling in .Net

Server controls like Datagrid, DataList, Repeater can have other child controls inside
them. Example DataGrid can have combo box inside datagrid. These child control do not
raise there events by themselves, rather they pass the event to the container parent (which
can be a datagrid, datalist, repeater), which passed to the page as “ItemCommand” event.
As the child control send there events to parent this is termed as event bubbling.

 
Leave a comment

Posted by on March 11, 2011 in Uncategorized

 

Concept of Boxing and Unboxing in .Net

Concept of Boxing and Unboxing

Boxing permits any value type to be implicitly converted to type object or to any interface type
implemented by value type. Boxing is a process in which  object  instances are created and copy
values in to that instance.
Unboxing is vice versa of boxing operation where the value is copied from the instance in to
appropriate storage location.
Below is sample code of boxing and unboxing where integer data type is converted in to object
and then vice versa.
Dim x As Integer
Dim y As Object
x = 10
‘ boxing process
y = x112
‘ unboxing process
x = y

Azhar Saiyed

 
Leave a comment

Posted by on March 11, 2011 in Uncategorized

 

Shadowing in .Net

Shadowing

When two elements in a program have same name, one of them can hide and shadow the
other one. So in such cases the element which shadowed the main element is referenced.
Below is a sample code, there are two classes “ClsParent” and “ClsShadowedParent”. In
“ClsParent” there is a variable “x” which is a integer. “ClsShadowedParent” overrides
“ClsParent” and shadows the “x” variable to a string.

Public Class ClsParent
    Public x As Integer
End Class
Public Class ClsShadowedParent    Inherits ClsParent
    Public Shadows x As String
End Class

Difference between Shadowing and Overriding

Following are the differences between shadowing and overriding :-
√ Overriding redefines only the implementation while shadowing redefines the
whole element.
√ In overriding derived classes can refer the parent class element by using “ME”
keyword, but in shadowing you can access it by “MYBASE”.

Thanks & Regards

Azhar Saiyed

 
Leave a comment

Posted by on March 11, 2011 in Uncategorized