About the author

Vijay Kodali
E-mail me Send mail

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2024

Disabling script debugging in VS 2008 and IE8

With VS 2008 and IE 8, JavaScript debugging is automatically enabled even if script debugging is set to disabled in IE8 settings. This will help developers in debugging scripts without having to change debugging features within browser. While this is a good feature for most developers, it takes up to 10X time to load a page that is heavy on client side scripts. 

How to disable script debugging in IE8?

Go to a Command Prompt (cmd) and Enter… 

reg add HKLM\SOFTWARE\Microsoft\VisualStudio\9.0\AD7Metrics\Engine\{F200A7E7-DEA5-11D0-B854-00A0244A1DE2} /v ProgramProvider /d {4FF9DEF4-8922-4D02-9379-3FFA64D1D639} /f 

To enable it again go to the Command Prompt and Enter...

reg add HKLM\SOFTWARE\Microsoft\VisualStudio\9.0\AD7Metrics\Engine\{F200A7E7-DEA5-11D0-B854-00A0244A1DE2} /v ProgramProvider /d {170EC3FC-4E80-40AB-A85A-55900C7C70DE} /f 

Tip from:Gregg Miskelly of Visual Studio team debugger team


Posted by vijay on Wednesday, July 1, 2009 2:40 PM
Permalink | Comments (1) | Post RSSRSS comment feed

Hide GridView AutoGenerate Columns

            //hide header column
            GridView1.HeaderRow.Cells[0].Visible = false;

            //hide column in data rows
            foreach (GridViewRow row in GridView1.Rows)
            {
                row.Cells[0].Visible = false;
            }

Categories: ASP.NET | ASP.Net 3.5
Posted by vijay on Thursday, March 26, 2009 8:37 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Visual studio Development Server problem in Vista

Problem:

Internet Explorer can not display the page.

Localhost not able to establish a connection on port..

getting the above messages when trying to run my application locally. I got this problem after installing this week's updates to Vista.  It messed up VS developer server settings. 

Apparently it was due to Definition Update for Windows Defender - KB915597 (Definition 1.53.256.0)

Solution:

Go to c:\Windows\System32\drivers\etc\ and open the file named hosts with a text editor and search for the line containing "::1"  and change "::1" to ":::1" by adding an extra ":" 

It solved the problem on one of my development machine. If it didn’t work, leave a comment.

Update:

Another solution from visual web developer team.

Update:

Same problem is discussed here and here


Posted by vijay on Thursday, March 12, 2009 1:23 PM
Permalink | Comments (42) | Post RSSRSS comment feed

onblur bug with RequiredFieldValidator and Google chrome browser

I came across a bug with Google chrome ver 1.0.154.43 while answering a problem in asp.net forums.

Problem:

Chrome browser ignores "onblur" event function for input box while it has Required field validator attached to it . Check this code..

  <input id="txt1" runat="server" type="text" maxlength="16" style="width: 127px" onblur= "formatSSN();"/>
  <asp:RequiredFieldValidator ID="Rfssn" runat="server" ControlToValidate="txt1" Display="None" ErrorMessage="SSN" 
     SetFocusOnError="True" EnableViewState="False">
  </asp:RequiredFieldValidator>
  <script language="javascript" type="text/javascript">
   function formatSSN() 
  {
    var ssn = document.getElementById("txt1").value;
    if(ssn.length == 9) 
        {
            document.getElementById("txt1").value= ssn.substring(0, 3) +"-" + ssn.substring(3, 5) + "-" + ssn.substring(5, 9); 
            return false;
        }
  }
  </script> 

The code works fine in IE6/7 & FireFox3, but not in Google chrome .

Solution:

I think the problem is with required field validator's SetFocusOnError property. Setting SetFocusOnError="false" for Rfv will fix it in chrome.


Posted by vijay on Saturday, January 24, 2009 8:15 PM
Permalink | Comments (5) | Post RSSRSS comment feed

TabContainer cannot have children of type error with Ajax tab control

Error:

 

You will get following error, if you try to add a sever control to AjaxTollkit’s tab panel.

 

TabContainer cannot have children of type 'System.Web.UI.WebControls.DataList'.

 

 

That’s because tab panel must be a server control, it should have an ID and runat =”server” attribute.

 

Solution:

 

Add an ID and runat =”server” attribute to that TabPanel, like this..

 

    <cc1:TabContainer ID="TabContainer1" runat="server">

        <cc1:TabPanel ID="TabPanel1" runat="server">

            <ContentTemplate>

                <asp:DataList ID="DataList1" runat="server">

                </asp:DataList>

                <asp:Label ID="Label1" runat="server" Text="Label">

                </asp:Label>

            </ContentTemplate>

        </cc1:TabPanel>

    </cc1:TabContainer>

 


Categories: AJAX | ASP.Net 3.5
Posted by Vijay on Wednesday, January 14, 2009 1:00 PM
Permalink | Comments (1) | Post RSSRSS comment feed

Validate Asp.Net FileUpload control

Here is an example to validate Fileupload control. This validation will check user to upload files of particular type/extension.

Client side validation:

 

<asp:FileUpload ID="UploadFile" runat="server" />
<asp:Button Text="Save" ID="btnSave" runat="server" OnClientClick="javascript:return ValidateUpload();" />     
 <script type="text/javascript" language="javascript">
    function ValidateUpload()
            {           
                var Upload_file = document.getElementById('<%= UploadFile.ClientID %>');                
                var myfile = Upload_file.value;               
                if(myfile.indexOf("doc")>0)
                {
                 alert('Valid Format');
                }
                else
                {
                 alert('Invalid Format');
                }            
            }
 </script>
Validating with RegularExpression validator:
<asp:FileUpload ID="UploadFile" runat="server" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Only Doc files are allowed" 
ControlToValidate="UploadFile" ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.doc|.DOC)$">
</asp:RegularExpressionValidator>

In this example, I checked  ".doc" file type but you can use this example for any file type. Just replace ".doc" with file type you would  like to check( "Xml", "wmv"...).


Categories: ASP.NET | ASP.Net 3.5
Posted by vijay on Thursday, October 16, 2008 8:26 PM
Permalink | Comments (3) | Post RSSRSS comment feed

jQuery now officially part of the .NET toolbox

Microsoft is going to make jQuery part of the official dev platform. JQuery will come with Visual Studio in the long term, and in the short term it'll ship with ASP.Net MVC. It is truly good news for ASP.Net developers

What is jQuery?

jQuery is a lightweight open source JavaScript library.

From jQuery website..

jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.

Blogs posts by Scott Guthrie and Scott Hanselman on this topic.


Posted by vijay on Tuesday, September 30, 2008 7:11 PM
Permalink | Comments (0) | Post RSSRSS comment feed

ASP.NET page rendering problems in FireFox and other browsers

I see questions asked frequently about FireFox rendering problems in Asp.Net forums.

What is "rendering engine"?

A rendering engine, also known as a layout engine, is the code that tells the browser how to display web content and available style information in the browser window

Here are some options to solve those:

  1. Always check  rendered web pages for XHTML compatibility using the W3C tests at   http://validator.w3.org . Most issues will fixed by fixing all non standards compliant HTML.
  2. Set clientTarget="UpLevel" in Page Directive. This will override automatic detection of browser capabilities and specifies how a page renders for particular browser clients.
  3. Here is link to a guide to make your page as accessible as possible.   http://www.anybrowser.org/campaign/abdesign.html

Categories: ASP.NET | ASP.Net 3.5
Posted by vijay on Thursday, September 25, 2008 7:43 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Disable Backspace to Previous Page in Asp.Net

The following code will allow backspace in textbox not on form. This code works perfectly in IE7/8,FireFox,Chrome

<script language=javascript>   
            
    function cancelBack()   
    {   
        if ((event.keyCode == 8 ||    
           (event.keyCode == 37 && event.altKey) ||    
           (event.keyCode == 39 && event.altKey))   
            &&    
           (event.srcElement.form == null || event.srcElement.isTextEdit == false)   
          )   
        {   
            event.cancelBubble = true;   
            event.returnValue = false;   
        }   
    }   
  
</script>   
<body onkeydown=cancelBack()>   

Tags:
Categories: ASP.Net 3.5 | JavaScript
Posted by vijay on Tuesday, September 2, 2008 9:50 AM
Permalink | Comments (6) | Post RSSRSS comment feed

Formatted Date based on the browser language setting

One of new feature that was added in Asp.net 3.5  is script globalization and localization. We can display date based on language setting of browser. Here is code snippet of displaying date in local language using script..

[code:c#]

   <script type="text/javascript">
        function formatDate() {
            var d = new Date();
            try {
                $get('Label1').innerHTML = d.localeFormat("dddd, dd MMMM yyyy HH:mm:ss");
            }
            catch (e) {
                alert("Error:" + e.message);
            }
        }
        window.onload
        {
            formatDate();
        }
    </script>

[/code]


Posted by vijay on Saturday, August 16, 2008 7:31 PM
Permalink | Comments (0) | Post RSSRSS comment feed