How to develop the good performance applications in ASP.NET 

Follow the below steps 

According to my knowledge i gather some steps to develop good performance applications in ASP.NET

1)Use the string builder for concatenation

2)Try partial page submission

3)Try to reduce the round tips with database

4)Try to reduce usage of viewstate

5)Avoid storing the too much data into session variable  and maintain session variable timeout property

6)Before deploying put  debug=false in web.config

7)Use the finally block along with try and catch blog to close the connections and close the files 

8)Do the validations at client side

9)Use is Page.IsPostBack to reduce unnecessary code calling

10) Try to maintain return statement to methods

11)Foreach loop is preparable compared with for loop

12)Use ArrayList instead of Array

13)Minimize the usage of  web server controls 

14)Try to reduce the usage of boxing and unboxing 

15) Try to avoid the recurs functions and nested loops

16)Place style sheet into header

17)Make a Javascript and CSS External

18)Return multiple result sets in a single database request

19)Close or dispose the connections after usage of database connection

20)Better to use Where conditions in select , Insert  and update queries 

21)Do not use the command builder at run time and better to use sqlcommandbuilder and oldbcommandbuilder

22)Use the stroedprocedures
  Be sure to use CommandType.StoredProcedure instead of CommandType.Text

23)Before you deploy your application , you must set tracing state as disable .

24)User server.transfer instead of response.redirect.

25)Use Cache:
Page output caching.
Page fragment caching.
Data caching.

26)Try to Reduce the cookie size
 Reference :
 Checklist: ASP.NET Performance: Click Here


How to call the ASP.Net Button click logic from model pop up Using  java script


JavaScript code
 function SubmitClick() {
                document.getElementById('text').innerHTML = "Do you want to continue ?";
               $('#divSubmitPopup').dialog({
                autoOpen: false,
                width: 300,
                height: 'auto',
                modal: true,
                resizable: false,
                draggable: true,
                autoResize: true,
                title: 'SamplePopUp :',
                position: 'center',
                buttons: {
                    "Continue": function () {
                        $('#btnSubmit').click();
                     
                    },
                    "Cancel": function () {
                        $(this).dialog("close");
                    }
                }
            });

            $('#divSubmitPopup').dialog('open');


        }

Html Code
                     
        <asp:Button ID="btnSubmit" runat="server" CssClass="button" Text="Submit" Style="display: none" OnClick="btnSubmit_Click" />

       <input id="htmlSubmit" type="button" value="Submit" runat="server" class="button" onclick="javascript:SubmitClick();" />

Points to Remembering
1)From html code call the function and implement the logic under function in javascript
2)Call the asp.net button from that logic .
please observe the above code then we can easily understand



How to read the data from GridView control 

ASPX.CS
       
foreach (GridViewRow row in gvAns.Rows) 
                        {
                            TextBox txtbox = (TextBox)row.FindControl("txtAnswer");
                            string str = txtbox.Text;
                       }


ASPX
  <asp:GridView ID="gvAnss" runat="server" AutoGenerateColumns="false" GridLines="None"
                        EmptyDataText="No records found" Visible="false" ToolTip="Answers">
                        <Columns>
                            <asp:TemplateField  Visible="true">
                                <ItemTemplate>
                                        <asp:TextBox ID="txtAns" runat="server" TextMode="MultiLine" 
                                        Text='<%#Eval("Ans")%>' CssClass=" editable stions">                       </asp:TextBox>
     
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>


Note:
gvAnswers is id of GridView  control 
txtAnswer  is id of TextBox control
Answers    is column name of table . it has taken from database table .
Here data inserted into gridview then read the data from gridview 
GridLines="None" property dosn't show gridlines


How to deploy the your ASP.NET application in IIS 

Follow the below steps to to deploy your application

1)Create the sample site (Your site)

2)Type the localhost in your browser  to know whether the IIS started or not


  your  iis was started

3)Open visual studio (Open your application)  and set start up page




4)Right click on your app and click ok


 5)publish your application in separate folder (Create new folder for publish)


  Then ckick OK

6)Set Publish method as file system from dropdown


7)select target location where do you want to publish your app and click the Delete all existing files prior to publish radio button


Then click publish button

8)Open the internet manager(click  windows key + R) and type inetmgr


9)Right click on the  Default site and click Add virtual directory



10)Give alias name what do you like and select the Physical path (Publidhed path ---   D:/publised)

 Then click OK

11)  click Ok


12)Right click on your app (it is look like folder)  and click "Convert to Application"


13)Select application pool

 click ok   then click ok

14) you will see your look like below
15)Now your happy because your app published in iis  . To see your app in browser  Right click on your app and  Go to manage application and select browse


16)Click Browse then you will get below screen




No comments: