Posts

Showing posts from 2010

Validate Date

private bool ValidateDate(string date) { try { string[] dateParts = date.Split('/'); string dte = dateParts.Length.ToString(); if (dte != "3") { return false; } if (dateParts[0].Length == 2 && Convert.ToInt32(dateParts[0]) { if (dateParts[1].Length == 2 && Convert.ToInt32(dateParts[1]) { if (dateParts[2].Length == 4 && Convert.ToInt32(dateParts[2]) >1900 ) { return true; } return false; } return false; } else return false; } catch { return false; } }

Change date format from MM/DD/YYYY to DD/MM/YYYY

string str = null; string[] strArr = null; //str = strdate; str = modifytext; char[] splitchar = { '/' }; strArr = str.Split(splitchar); string[] field = str.ToString().Split(("/").ToCharArray()); //string[] dateparts = new string[4]; string DDDD = field[0].ToString(); string MMMM = field[1].ToString(); string YYYY1 = field[2].ToString(); if ((field[0].ToString() == "1") || (field[0] == "2") || (field[0] == "3") || (field[0] == "4") || (field[0] == "5") || (field[0] == "6") || (field[0] == "7") || (field[0] == "8") || (field[0] == "9")) { ...

How to change value on selection of dropdown list control in datagid

How to change value on selection of dropdown list control in datagrid. // drpmodify is dropdown list. protected void drpmodify_SelectedIndexChanged(object sender, EventArgs e) { DropDownList list = (DropDownList)sender; TableCell cell = list.Parent as TableCell; DataGridItem item = cell.Parent as DataGridItem; DropDownList index = (DropDownList)item.Cells[10].FindControl("drpmodify"); DropDownList drpmodify12 = null; drpmodify12 = (DropDownList)index; TextBox txtupdate = null; txtupdate = (TextBox)item.Cells[11].FindControl("TxtUpdate"); if ((drpmodify12.SelectedValue == "N") || (drpmodify12.SelectedValue == "M") || (drpmodify12.SelectedValue == "NE") || (drpmodify12.SelectedValue == "DU") || (drpmodify12.SelectedValue == "D") || (drpmodify12.SelectedValue == "I")) { txtupdate.Text = ""...

Welcome to My Blog

Thank you for visiting myPage, I am Varun Sharma, a Software Engineer by profession. I work for a Technology Major; I Design, Develop. This is what I do 9 am to 5 pm Monday to Friday at my workplace.

How to Print a Report made in Web Page

First of all insert the printable area into a Div. then write below code in Page load Suppose your Print button Id = btnPrint and div id = printdiv btnPrint.Attributes.Add("Onclick", "javascript:CallPrint('printdiv');"); pass this div id to the javascipt function written in HTML function CallPrint(strid) { var prtContent = document.getElementById(strid); var WinPrint = window.open('','','letf=0,top=0,width=1000,height=1000,toolbar=0,scrollbars=0,status=0'); WinPrint.document.write(prtContent.innerHTML); WinPrint.document.close(); WinPrint.focus(); WinPrint.print(); WinPrint.close(); prtContent.innerHTML=strOldOne; }

Run Crystal Report in VB.net 2005 Windows application using MS Access Database

1.) Add button on the form and write code behind the button frmviewreport.Show() frmviewreport is the another form on which we add the CrystalReportViewer

Maintain Scroll Position of Gridview

1.) Add two hidden textboxes namely hidDiv1 and hidDiv2 input id="hidDiv1" type="hidden" name="hidden1" runat="server" input id="hidDiv2" type="hidden" name="hidden2" runat="server" 2.) Add this code in the aspx page under script tag script type="text/javascript" language="javascript" function saveScrollPos1() { document.getElementById('hidDiv1').value = document.getElementById('div1').scrollTop; } function SetScrollPos1() { document.getElementById('div1').scrollTop = document.getElementById('hidDiv1').value; } function saveScrollPos2() { document.getElementById('hidDiv2').value = document.getElementById('div2').scrollTop; } function SetScrollPos2() { document.getElementById('div2').scrollTop = document.getElementById('hidDiv2').value; } /script 3.) under the onload event of body tag body onload="SetScroll...

How to Accessing the Website IP Address

Label1.Text="You are Accessing this website From IP Address: " + Request.ServerVariables["REMOTE_ADDR"].ToString();