Posts

Disable Back Browser Button in web Page

Image
This example will show how to disable Back button in your browser. To achieve this objective, the javascript will be use to redirect back to the current page if the user click on the browser back button and give message to user. So let see the example. I'll set the script at HEAD element and use onpageshow and  onload event in the body element. The Javascript put in Head element <script type="text/javascript">         window.history.forward();         function noBack() { window.history.forward(); document.getElementById("Message").innerHTML = "You cannot Go Back"; }     </script> The Html/Aspx/Jsp page : : Head element : <body onpageshow="if (event.persisted) noBack();" onload="noBack();" > : : body content  <div id="Message" style="color:red;">  </div> : : </body> </html> The Output If the user click on the browser back button, the script will automatically redirect to

Remove Whitespace From aspx pages - Performance with page speed

Some web page have a thousand line of html code and it will increase the size of the page to download to users. It is often possible to make a content of web page fewer bytes(their size) without changing the appearance or function of the page. This approach will improve download time and makes the page load faster. The question how to make this happen without extra effort to remove the space manually and without effect the development time. This is a snippet code that you need to put in your Master page so that the code will automatically override the Render Event in asp.net The Code to put in Master Page The Attribute/Field for masterpage private static readonly Regex REGEX_BETWEEN_TAGS = new Regex(@">\s+<", RegexOptions.Compiled); private static readonly Regex REGEX_LINE_BREAKS = new Regex(@"\n\s+", RegexOptions.Compiled); The Override Method /// <summary>         /// Initializes the <see cref="T:System.Web.UI.HtmlTextWriter">&l

Understanding The Web Page Processing(End To End)

Image
A common way to think about the Web is that there is a browser on one end of a network connection and a web server with a database on the other end.  Simplified web architecture model The simplified model is easy to explain and understand, and it works fine up to a point. However, quite a few other components are actually involved, and many of them can have an impact on performance and scalability.The next picture shows some of them for web sites based on ASP.NET and SQL Server. Web architecture components that can impact performance All of the components in picture above can introduce delay into the time it takes to load a page, but that delay is manageable to some degree. Additional infrastructure-oriented components such as routers, load balancers, and firewalls aren’t included because the delay they introduce is generally not very manageable from a software architecture perspective. In the following list, I’ve summarized the process of loading a web page. Each of these steps offers

Simple Image Resizer Tools - C# Example

Image
This example will use the  Image Resizer Class from previous post . I have change a little bit on the class so that i can use it for my example image resizer tools. ImageResizer Tool Requirement ImageResizer tool will require user to choose the image to resize. Only JPG image supported. After that user can simply put the width and height to change the selected image width and height. User can choose is either to use aspect ratio. After Complete , user will prompt to open the new image after resize. The tools use .NET version 4. The GUI of ImageResizer Tool The Code Behind   private string _ImageName;         private string _ImageExtension;         public Form1()         {             InitializeComponent();             TPercentage.Text = "0";             tWidth.Text = "0";             THeight.Text = "0";         }         private void button1_Click(object sender, EventArgs e)         {             openFileDialog1.Filter = "JPEG Files (.JPG)|*.JPG

Example to disable save as certain file type in SSRS Report Viewer

Image
SQL Server Reporting Service(SSRS) is a full range of ready-to-use tools and services to help you create, deploy, and manage reports for your organization, as well as programming features that enable you to extend and customize your reporting functionality. The Report Viewer provide functionality to save the report as a pdf, word and also as a excel format. Sometime organization require this feature, sometime not. This is how to disable save as function in Report Viewer(SSRS). The example will invoke methode pre-render in Report Viewer Controller. The ASPX Page <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"     Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %> : : : <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat

Multiple Button in MVC 4

Many developers now have experience on ASP.NET Web development but when microsoft introduce the new solution for web development(ASP.NET Model View Controller - MVC framework) back at April 2009, not all developers like it. Because ASP.NET is just drag and drop, and easy to use different with ASP.NET MVC. Recently i have develop one web application using MVC framework and this is my first experience using it i never done it before... Just want to share some information for newbie like me to have a multiple button in one form. Sound like very easy but it is very popular in google search keyword "Multiple Button MVC" .. ok here the solution i figure out : Solution One The View(cshtml)     @using (Html.BeginForm("ActionTaken", "TestController"))       {            <button name="button" value="ActionOne" class="button" style="width: 200px;">               test1</button>            <button name="button

How to open file using their default external viewer - C#

When write the application, some of the activity is to create file, convert file, etc . After create the file, the program should prompt user to open the created file using their respective default external viewer . Letsay you create .pdf file, so the default application to open the file is Adobe Reader . The example will ask user is either user want to open file or not, if user agreed to open the file created, then the application will open file using their respective default external viewer depend on the file extension . The code    string outFilePath = File.Create("PDFFILE.pdf");                               DialogResult dr = MessageBox.Show("Open the rendered file in an external viewer?", "Open Rendered File", MessageBoxButtons.YesNo);   if (dr == DialogResult.Yes)   {       System.Diagnostics.Process.Start(outFilePath);   } By Mohd Zulkamal NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and