RSS

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

 

Improve perfomance in asp.net web

While developing any web site one should keep some point into their mind.

1. Set debug=false under compilation as follows:-

2. Turn off Tracing unless until required.

3. Turn off Session State, if not required.

4. Select the Release mode before making the final Build for your application. This option is available in the Top Frame just under the Window Menu option. By default, the Mode is Debug

5. Disable ViewState as and when not required.

6. EnableViewState=”false”

7. Avoid frequent round trips to the Database.

8. Use Caching to improve the performance of your application.

9. Validate all Input received from the Users.

10. Use Finally Method to kill resources.

11. The String and Stringbuilder Magic.
It is nice to use Stringbuilder instead of String when string are Amended.
String occupy different memory location in every time of amended where stringbuilder use single memory location

12. Never use object value directly; first get object value in local variable and then use. It takes more time then variable reading.

13. Before doing a bulky ASP code processing, you can check to make sure Response.IsClientConnected.

14. As always, avoid session variables because each ASP page runs in a different thread and session calls will be serialized one by one. So, this will slow down the application. Instead of session variables you can use the QueryString collection or hidden variables in the form which holds the values.

15. Enabling buffering will improve the performance, like Response. Buffer=True.

16. Data listing is more time consume when large data are retrieve from database.
Paging will display only particular data but take load of all data.
Use arraylist and take all data into this then fetch data from arraylist by Particular Page Number and bind only those data.

17. Use JavaScript file instead of writing in same file.
Use single css file instead of multiple css file.
· Try your best to combine all your CSS based classes into a single .css file as lot of .css files will cause a large amount of requests, regardless of the file sizes.
· .css files are normally cached by browsers, so a single and heavy .css file doesn’t cause a long wait on each page request.
· Inline .css classes could make HTML heavy, so again: go ahead with a single.css file.
Reduce cookie size

19. Compress CSS, JavaScript and Images
Online compressors are available; to compress file please refers following web and put your file content into there and get optimize code.
http://iceyboard.no-ip.org/projects/css_compressor for CSS compression
http://www.xtreeme.com/javascript-optimizer/ . For JS Compression

20 .Use Cache appropriately
i. Page output caching:

ii. Page fragment caching:
Write a previous code into each User Control
iii. Data caching:

Protected void Page_Load(Object src, EventArgs e) {
DataView dv = (DataView)Cache.Get(“EmployeesDataView”);
if (dv == null) { // wasn’t thereSqlConnection conn =
new SqlConnection(“server=localhost;uid=sa;pwd=;database=Test”);
SqlDataAdapter da =new SqlDataAdapter(“select * from Employees”, conn);
DataSet ds = new DataSet();da.Fill(ds, “Employees”);
dv = ds.Tables[“Employees”].DefaultView;
Cache.Insert(“EmployeesDataView”, dv);onn.Close();}
else
Response.Write(“aa”);
lb1.DataSource = dv;
lb1.DataTextField = “Name”;
lb1.DataValueField = “Age”;
DataBind();}

Use server side compression software such as Port80???s http://www.port80software.com/products/httpzip/

 
3 Comments

Posted by on March 9, 2011 in Uncategorized