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

8th Prize Winner of Community-Credit January 2009

I have won the 8th Prize in Community-Credit January 2009 contest.It has been an great experience to be a part of the full community and do what I like to do. But to be awarded for doing what you love to do is great.

 


Categories: General | Web Development
Posted by vijay on Wednesday, February 18, 2009 7:53 AM
Permalink | Comments (0) | 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

Dynamic Accordion control same ID _header error

Multiple controls with the same ID '_header' were found. FindControl requires that controls have unique IDs.

 I got this error, when I tried adding multiple accordion panes to the accordion control in code behind. The problem is with duplicate ID for the panes. Setting unique ID's to dynamic panes will fix the problem.

<cc1:accordion id="Accordion1" runat="Server" selectedindex="0" 
  headercssclass="accordionHeader" contentcssclass="accordionContent" 
  autosize="None" fadetransitions="true" transitionduration="250"
  framespersecond="40" requireopenedpane="false" suppressheaderpostbacks="true">
</cc1:accordion>

In Code behind:

for (int i = 0; i < 3; i++)
{
    AccordionPane pane1 = new AccordionPane();
    //Here i used Guid for uniqueness
    pane1.ID = "AccordionPane" + Guid.NewGuid().ToString();
    Label lbl = new Label();
    lbl.Text = "New pane";
    pane1.Controls.Add(lbl);
    Accordion1.Panes.Add(pane1);
}


Categories: AJAX | Web Development
Posted by vijay on Monday, January 12, 2009 12:39 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Microsoft releases CTP of Visual studio 2010 and Dot net framework 4.0

According to Scott Guthrie VS2010 was built using the Windows Presentation Foundation. VS2010 will offer features like multi-monitor support, richer code editing and richer code visualization.

Check this .Net 4.0 framework poster


Tags:
Categories: General
Posted by vijay on Thursday, October 30, 2008 7:36 PM
Permalink | Comments (0) | 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