Pages

Accessing a Xml File on Server using JavaScript

  1. Create a XML file static or dynamic in Server
  2. Write a javascript function as shown JavscriptFunctionCode shown below .
  3. Call a method loadXMLDoc("XML filename")
  4. Parse XMl as shown Pseduo Codefor futher ways to parse XML document visit http://www.w3schools.com/dom/

Javasript Function Code (ref:w3schools)

function loadXMLDoc(dname) { try //Internet Explorer { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); } catch(e) { try //Firefox, Mozilla, Opera, etc. { xmlDoc=document.implementation.createDocument("","",null); } catch(e) {alert(e.message)} } try { xmlDoc.async=false; xmlDoc.load(dname); return(xmlDoc); } catch(e) {alert(e.message)} return(null); }

Pseduo Code

/////Xml File <?xml version="1.0" encoding="iso-8859-1" ?> <shop> <product> <category>Electronics</category > <pname>LapTop</pname> <cost>50</cost> </product> <product> <category>Entertainment</category > <pname>Lg Tv</pname> <cost>500</cost> </product> </shop> //////////////////////////////// ///javscript calling code xmlDoc=loadXMLDoc("Products.xml"); //one of the way of parsing xml eleement document.write(xmlDoc.getElementsByTagName("category")[0].childNodes[0].nodeValue); ////////////////////////////////

Sorting & Filtering Data Using DataView In Asp.net 2.0

Steps:

  1. Create Dataview Object pass DataTable object to constructer of Dataview class (Assume datatable object is Created)
  2. To sort Data use property called 'Sort' in Dataview object as peseduoCode shown below .
  3. To Filter Data use RowFilter or RowStateFilter.as peseduoCode shown below
  4. RowFilter is use as where clause in sql statment use all operaters use in where clause
  5. RowState Filter provide base on DataRow object RowState property.It is use to retrive version information with DataTable using one of the DataViewRowState enermuation

DataViewRowState Enermuation

  • Added:Retervies the current DataRowVersion of DataRow Object that row state of Added
  • CurrentRows:Reterive all rows that current DataRowVersion
  • Deleted:Reterive the original DataRowVersion of DataRow object that have a RowState of deleted.
  • ModifiedCurrent:Reterives the Current DataRow Version of DateRow object that have RowState of modified
  • ModifiedOriginal:Reterives the Original DataRow Version of DateRow object that have RowState of modified
  • None:Clears Row state filter property
  • OriginalRows:Reterive the DataRow object that have original DataRowVersion.
  • Unchanged: Reterive DataRow object that have row state of unchanged

PseduoCode

////Dataview Sort
DataView view = new DataView("datableobject"); view.Sort= "columname1 ASC , columnname2 DESC"; ///Binding datasource gird; gridobject.DataSource=view; gridobject.DataBind();
////////////////// ////Dataview RowFilter
view.RowFilter ="columname1 like '%A' and columname2 < 26 "; //Do Some Thing
////////////////////// ////DateView RowState property
view.RowStateFilter = DataRowState.Added //DataRowState.Enumerationnames //Do Some Thing

Create a Custom colums in GridView

  1. Add CustomBoundField file to your project (c# libaray project for creation of dll or in web application directly access it)
  2. To acces file in your code behind follow the Pseudo code below .If you are using as dll add refence then access in your application

Pseduo code

DataSet ds = new DataSet(); ds.Tables.Add(); ds.Tables[0].Columns.Add("UserName"); // ds.Tables[0].Columns.Add("xyz"); ds.Tables[0].Rows.Add(ds.Tables[0].NewRow()); // ds.Tables[0].NewRow(); ds.Tables[0].Rows[0][0] = "sdfg1"; //ds.Tables[0].Rows[0][1] = "0"; CustomBoundField cbound = new CustomBoundField(); cbound.HeaderText = "Name"; cbound.DataField = "UserName"; cbound.Editable = true ; CustomBoundField cbound1 = new CustomBoundField(); cbound1.HeaderText = "tempcolum1"; cbound1.ShowCheckBox = true; CustomBoundField cbound2 = new CustomBoundField(); cbound2.HeaderText = "tempcolum2"; cbound2.ShowRadioButton = true; CustomBoundField cbound3 = new CustomBoundField(); cbound3.HeaderText = "tempcolum3"; cbound3.ShowTextBox = true; CustomBoundField cbound4 = new CustomBoundField(); cbound4.HeaderText = "tempcolum4"; cbound4.ShowDropDown = true; GridView1.Columns.Add(cbound); GridView1.Columns.Add(cbound1); GridView1.Columns.Add(cbound2); GridView1.Columns.Add(cbound3); GridView1.Columns.Add(cbound4); GridView1.AutoGenerateColumns = false; GridView1.DataSource = ds; GridView1.DataBind() ;

CustomBound Field class (ref:Codeproject)

public class CustomBoundField : DataControlField { public CustomBoundField() { // // TODO: Add constructor logic here // } #region Public Properties /// /// This property describe weather the column should be an editable column or non editable column. /// public bool Editable { get { object value = base.ViewState["Editable"]; if (value != null) { return Convert.ToBoolean(value); } else { return true; } } set { base.ViewState["Editable"] = value; this.OnFieldChanged(); } } /// /// This property is to describe weather to display a check box or not. /// This property works in association with Editable. /// public bool ShowCheckBox { get { object value = base.ViewState["ShowCheckBox"]; if (value != null) { return Convert.ToBoolean(value); } else { return false; } } set { base.ViewState["ShowCheckBox"] = value; this.OnFieldChanged(); } } public bool ShowRadioButton { get { object value = base.ViewState["ShowRadioButton"]; if (value != null) { return Convert.ToBoolean(value); } else { return false; } } set { base.ViewState["ShowRadioButton"] = value; this.OnFieldChanged(); } } public bool ShowTextBox { get { object value = base.ViewState["ShowTextBox"]; if (value != null) { return Convert.ToBoolean(value); } else { return false; } } set { base.ViewState["ShowTextBox"] = value; this.OnFieldChanged(); } } public bool ShowDropDown { get { object value = base.ViewState["ShowDropDown"]; if (value != null) { return Convert.ToBoolean(value); } else { return false; } } set { base.ViewState["ShowDropDown"] = value; this.OnFieldChanged(); } } /// /// This property describe column name, which acts as the primary data source for the column. /// The data that is displayed in the column will be retreived from the given column name. /// public string DataField { get { object value = base.ViewState["DataField"]; if (value != null) { return value.ToString(); } else { return string.Empty; } } set { base.ViewState["DataField"] = value; this.OnFieldChanged(); } } #endregion #region Overriden Life Cycle Methods /// /// Overriding the CreateField method is mandatory if you derive from the DataControlField. /// /// protected override DataControlField CreateField() { return new BoundField(); } /// /// Adds text controls to a cell's controls collection. Base method of DataControlField is /// called to import much of the logic that deals with header and footer rendering. /// /// A reference to the cell /// The type of the cell /// State of the row being rendered /// Index of the row being rendered public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex) { //Call the base method. base.InitializeCell(cell, cellType, rowState, rowIndex); switch (cellType) { case DataControlCellType.DataCell: this.InitializeDataCell(cell, rowState); break; case DataControlCellType.Footer: this.InitializeFooterCell(cell, rowState); break; case DataControlCellType.Header: this.InitializeHeaderCell(cell, rowState); break; } } #endregion #region Custom Protected Methods /// /// Determines which control to bind to data. In this a hyperlink control is bound regardless /// of the row state. The hyperlink control is then attached to a DataBinding event handler /// to actually retrieve and display data. /// /// Note: This control was built with the assumption that it will not be used in a gridview /// control that uses inline editing. If you are building a custom data control field and /// using this code for reference purposes key in mind that if your control needs to support /// inline editing you must determine which control to bind to data based on the row state. /// /// A reference to the cell /// State of the row being rendered protected void InitializeDataCell(DataControlFieldCell cell, DataControlRowState rowState) { //Check to see if the column is a editable and does not show the checkboxes. if (Editable & !ShowCheckBox & !ShowRadioButton & !ShowTextBox & !ShowDropDown) { string ID = Guid.NewGuid().ToString(); TextBox txtBox = new TextBox(); txtBox.Columns = 5; txtBox.ID = ID; txtBox.DataBinding += new EventHandler(txtBox_DataBinding); cell.Controls.Add(txtBox); } else { if (ShowCheckBox) { CheckBox chkBox = new CheckBox(); cell.Controls.Add(chkBox); } else if (ShowRadioButton) { RadioButton rdBttn1 = new RadioButton(); rdBttn1.GroupName = "grp1"; rdBttn1.Text = "Yes"; RadioButton rdBttn2 = new RadioButton(); rdBttn2.GroupName = "grp1"; rdBttn2.Text = "No"; cell.Controls.Add(rdBttn1); cell.Controls.Add(rdBttn2); } else if (ShowTextBox) { TextBox txtBox = new TextBox(); cell.Controls.Add(txtBox); txtBox.Columns = 5; } else if (ShowDropDown) { DropDownList ddl = new DropDownList(); cell.Controls.Add(ddl); // txtBox.Columns = 5; } else { Label lblText = new Label(); lblText.DataBinding += new EventHandler(lblText_DataBinding); cell.Controls.Add(lblText); } } } void lblText_DataBinding(object sender, EventArgs e) { // get a reference to the control that raised the event Label target = (Label)sender; Control container = target.NamingContainer; // get a reference to the row object object dataItem = DataBinder.GetDataItem(container); // get the row's value for the named data field only use Eval when it is neccessary // to access child object values, otherwise use GetPropertyValue. GetPropertyValue // is faster because it does not use reflection object dataFieldValue = null; if (this.DataField.Contains(".")) { dataFieldValue = DataBinder.Eval(dataItem, this.DataField); } else { dataFieldValue = DataBinder.GetPropertyValue(dataItem, this.DataField); } // set the table cell's text. check for null values to prevent ToString errors if (dataFieldValue != null) { target.Text = dataFieldValue.ToString(); } } protected void InitializeFooterCell(DataControlFieldCell cell, DataControlRowState rowState) { CheckBox chkBox = new CheckBox(); cell.Controls.Add(chkBox); } protected void InitializeHeaderCell(DataControlFieldCell cell, DataControlRowState rowState) { // TODO:if wnat add label to headet text then use it else comment it //Label lbl = new Label(); //lbl.Text = "Name";//this.DataField; //cell.Controls.Add(lbl); } void txtBox_DataBinding(object sender, EventArgs e) { // get a reference to the control that raised the event TextBox target = (TextBox)sender; Control container = target.NamingContainer; // get a reference to the row object object dataItem = DataBinder.GetDataItem(container); // get the row's value for the named data field only use Eval when it is neccessary // to access child object values, otherwise use GetPropertyValue. GetPropertyValue // is faster because it does not use reflection object dataFieldValue = null; if (this.DataField.Contains(".")) { dataFieldValue = DataBinder.Eval(dataItem, this.DataField); } else { dataFieldValue = DataBinder.GetPropertyValue(dataItem, this.DataField); } // set the table cell's text. check for null values to prevent ToString errors if (dataFieldValue != null) { target.Text = dataFieldValue.ToString(); } } #endregion }

Converting rows into colums In Sql Server for Cross Tab Report

Sometimes it is necessary to rotate results so that [the data in] columns are presented horizontally and [the data in] rows are presented vertically. This is known as creating a PivotTable®, creating a cross-tab report, or rotating data. visit : http://www.sqlservercentral.com/articles/T-SQL/63681/ .It require registration .Enjoy learning

Creating Document library in Moss2007

1)Click on site setting select libirary setting 2)Enter Name ,Description ,Navigation,Document version history 3)Select Document tempelate as per requirment 4)Once document libirary created At top you find option (New ,Upload,Action,Setting) 5)New ->to create a document and save it 6)Upload -> To upload single doc or multiple docments 7)Action->Edit Datasheet ,Open window explore to drag drop document NOTE:If using office 2007 save in word 97-2003 format only

Different Custom Controls in Asp.net2.0

They are 3 primary custom control in Asp.net2.o 1)User control : A user Control is a template Control that provide extra behaviour to allow consitent control added to the user control in GUI .This control is added to the user control template file i.e ascx 2)Custom Web control : A custom web control is control that inherits from a web control.Write all the code for Rendering the control or inherit from existing web control and provide extra behaviour. 3)Composite control : A custom web control that can contain constiuent controls.The constiuent control are added to composite control via code to class file that defines the control.The class file compiled to a .dll

Create a modal popup in javascript without ajax

Here i am create a popup window alternate to javascript popups 1)we have to create 2 html files 2)First html file name is modalpopup page (you can have any name for page) 3)Second html file is dialog page (you can have any name for page) 4)Uisng window .showModalDialog() method .we can diplay a modal dialog 5)Note for example purpose i used HTML pages you can proceed with other type files 6)You can assign any image to image tag in my example and update CSS according to your requirment Note :For alternate option of modal dialog visit: www.jquery.com
////////// pseduo code of modalpoppage //javscript code function fun() { window.showModalDialog("dialogpage.html",window,"dialogHeight:100px;dialogWidth: 283px; dialogTop: 286px; edge: Raised; center: Yes; resizable: Yes; status: No;"); } call function on buttton click event ///////////// pseduo code of dialogpage ////////////// HTML code <table align="center"> <tr> <td> <img src="" /> </td> <td> Information to be display </td> </tr> <tr> <td> <input type="Button" value="Yes" onclick="javascript:alert('Yes is clicked');" /> </td> <td> <input type="Button" value="No" onclick="javascript:window.close();" /> </td> </tr> </table> //////////////

Create subsite in Moss2007

create a subsite in sharepoint (Assume parent site created) 1)Click on site setting tab 2)Under Web pages section click on sites and workspaces 3)Enter Title & description & url and modifed permission if required 4)Select template

Creating different session ID on new window

1)create object of SessionIDManager ///// System.Web.SessionState.SessionIDManager s1 = new System.Web.SessionState.SessionIDManager(); ////// 2)Remove session id create a new session Id /////// s1.RemoveSessionID(HttpContext.Current); s1.CreateSessionID(HttpContext.Current); /////// 3)Assign value to session ////// Session["page1Session"] = "page1 session"; /////// 4)In new page assign session value as above 5)To look session Id in each page write Response.Write(Session.SessionID)

Creation of list in share point 2007 or MOSS 2007

1)Click site action tab (Assume a site is created) 2)Click on create 3)Under Customlists section 4)Select Custome list 5)Enter Display name & Description 6)If want display list at left side pane (quick launch ) of check yes else no 7)By Default one colum is viewable i.e title 8)To edit Title colum name click on settings tab select list setting 9)Under Colum section click on title then rename colum name edit seeting as your requirment 10)Create a new colum under seting tab click on new colum then provide colum name,type ,description 11)To make colum as required filed select Reauired colum information 12)To Disable colum from default view uncheck default view colum 13)Edit any colum follow step 8 & 9 except colum name is differ 14)Note Default colum create when a list created Attachment,created,created by,edit,id,modified,modified by,type,version so on 15)To edit view of any list under view select modify view To enable any colume to see in default view check the display & order of display can be varied 16)To Delete a list click on setting then select list setting under permissin and managment click on delete list

Different type of events Available in Javscript

Events associated with Mouse: onmousemove: If the user moves a button, then the events associated with onmousemove fire. onclick: onclick events fire when the mouse button clicks. ondblclick: The event ondblclick fires when the mouse button is double clicked. There are also some events associated with the mouse pointer position such as: onmouseout: onmouseout event fires if the mouse pointer position is out of focus from the element. onmouseover: onmouseover event fires if the mouse pointer position is in focus of the element position. The above are some of the various mouse events available in JavaScript. Events associated with Keyboard: onkeydown onkeyup onkeypress onkeydown: onkeydown event fires when key is pressed. onkeyup: onkeyup event fires when key is released. onkeypress: The event onkeypress fires if the onkeydown is followed by onkeyup. There are many additional events available in JavaScript. A few are listed below: onerror: onerror event fires when an error occurs. onfocus: When a element gains focus, onfocus event fires or executes. onblur: In contrast to an onfocus event, this event fires when the element loses its focus. Both onfocus and onblur may be used for handling validation of forms. onsubmit: The event onsubmit fires when the command form submit is given. This event is used for validating all fields in the form before submitting the form. onload: onload event automatically executes as soon as the document fully loads. This loads when the user enters the page. This is a commonly used event. This event is used to check compatibility with the browser version and type. Based on this compatibility, the appropriate version of a page will then load. onunload: In contrast to onload event, the onunload event fires when the user leaves the page.

Running Window Application using Window Service

How to run window apllication in specfic interval from window service 1)Create window service application(Assume Creation of window service known) 2)Use Namespace system .Timer add timer.start in start method of windowservice 3)Add Time elapsed event handler mechanism in start method of window service 4)In Timeelapsed event add following line code Process proc; proc = new Process(); proc.StartInfo.FileName = @"C:\windowapplicationName.exe"; proc.StartInfo.Arguments = "jhgj";[optional] proc.StartInfo.WindowStyle = ProcessWindowStyle.Maximized; proc.Start(); 5)After install service in service controler right click on service name then click properties under login tab enable Allow service to interact with desktop (For Automatic enable review code given below add name space Microsoft.win32 in code) 6)Start service
Declartion in Class Member Section /////////// Process p = new Process(); // int ncount = 0; int iProcessID = 0; System.Timers.Timer objtimer = new Timer(1000); ////////// Code for start Method ////////// this.objtimer.Enabled = true; this.objtimer.Start(); this.objtimer.Elapsed += new System.Timers.ElapsedEventHandler(timer1_Elapsed); //Automatatically enable window service for inter active desktop // Here is where we set the bit on the value in the registry. //Reference from CodeProject.com // Grab the subkey to our service RegistryKey ckey = Registry.LocalMachine.OpenSubKey( @"SYSTEM\CurrentControlSet\Services\Sample", true); // Good to always do error checking! if (ckey != null) { // Ok now lets make sure the "Type" value is there, //and then do our bitwise operation on it. if (ckey.GetValue("Type") != null) { ckey.SetValue("Type", ((int)ckey.GetValue("Type") | 256)); } } ///////// Code for Timer Elapsed event ///////// ///here if condtion are used to check not to run same process again if process is already running try { if (iProcessID != 0) { Process[] objProcesses = System.Diagnostics.Process.GetProcesses(); bool IsExists = false; foreach (Process prc in objProcesses) { if (prc.Id == iProcessID) { IsExists = true; } } if (IsExists == false) iProcessID = 0; } if (iProcessID == 0) { Process proc; proc = new Process(); proc.StartInfo.FileName = @"C:\TrayDemo.exe"; proc.StartInfo.Arguments = "jhgj"; proc.StartInfo.WindowStyle = ProcessWindowStyle.Maximized; if (proc.Start()) { iProcessID = proc.Id; } } } catch (Exception ex) { //MessageBox.Show(ex.ToString()); } /////////////

create a new site in share point 2007

1)Assume web application is created 2)Open central administrator 3)Click on application management tab 4)Under sharepoint site management section click on create site collection 5)To change a defalut web application click on web application link 6)Provide tiltle,description ,url 7)Select template 8)Provide user name i.e winows user

Create a new or extend web application in Moss2007

1)open centeral administrator tool 2)Click on application tab 3)Click on create or extend web application 4)select exist web application or creat anew web application Step :create a new web application changes if required 1)Select existing web site or create anew website (change description if required) 2)change port number if required Leave default options 1)Authentication 2)Anonymous 3)Use security socket layer(ssl)4)URL 5)application pool Changes secrity account of application pool 1)select predined i.e network service.if want user name and password select configurable Change iis 1)select restart iis automaticaly (prefered) Leave defaultsetting of data base Step :Extend web application 1)Every thing same as above except web application click to choose web application

Portals in sharepoint

Portal 1)Connect your people to information and expertise:To share critical bussines and experise information and make a better decision 2)Connect people for key bussiness application:To stream line devlopment new composite application 3)Connect your people to role specfic resource:Allow roles to create in your portal and acces revalance resources

Collabration and Social computing in Moss2007

Collabration:It provide enviroment to working togther in teams and communnity to share information in differnent platform Social Computing:It helps us creating or recreating social convention social context online through the use of software & technology Purpose of Collabration and Social computing in Moss2007 1)Empower team with collabrative workspace:Moss provide to create own workspace to share asset with in team,department with in the oraganization 2)Connect the oragnization through portals: Moss provide to connect to people with line of bussines data ,experts,and bussiness process across the oraganization 3)Enable communities with social computing Tools: It provide a tool to set of social computing capabalities with their existing workspace and portal infrastructer 4)Reduce Cost and Complexity for IT by using integerated Infrastructer ,Existing investment and an Extensible architectual platform :Organizatiion maintain lower cost of ownerships and more easily meet bussines demand

What is Moss2007 its purpose

Moss :Microsoft office share point server Moss is a new server program that is part of office 2007 Moss provide services 1)Collabration:Allow team work together effectively ,collabrate on and publish document.maintain task list ,implement worflow and share information through the use of wiki and blog 2)Portals:Create my personal site portal to share information with other and personalize the user expierence 3)Enterpise Search:Quickly easly find people ,expertise ant content in bussines application 4)Enterprise Content Managment:Create and manage document,records and web content 5)Bussiness process and forms:Create workflow and elecronic form to automate and stream line business process 6)Bussiness Intelligence :Allow information worker to easy access critical business information , anaylse and view data ,and publish reports to make more informed decesion Moss integeration with Office 2007 1)Powerpoint 2007 is used to create slide libiraries for presentation slide for a user and notified update so on 2)Office designer to create templates Moss Integeration with .net 1)Create event on list , webparts WSS varying with Moss Windows share point service (wss) It provide site template for collabrationg with colleagues and setting up meeting template Moss :In addtion to wss template .It provide site template related to enterprise and publishing

Different catetgories of Culture in .net

1)Invarient Culture This culture categoary is cultur -insensitive.This Culture is to used essentialy a default culture when consitency is desired.It used to create trial application with harde code expiration date .As Invarient Culture is not based on any language .It simply the task of comparing dates 2)Neutral Culture A Neutral culture is associated with a language but has no relationship with countries or region .The english spoken in United State is differ from Great Britan.It contain 2 characters (en)English,French(fr) and Spanish(sp) 3)Specfic Culture This is most precise of that three categories and is reprsented by a neutral culture ,a hyphen ant then a specfic culture abberevation it reprsent a region/country .For example (en-US ) en represent a neutral culture & US represent a specfic culture

GuideLines of Best HTML layout of Variety of culture

1)Avoid using absolute postioning and sizes for control 2)Use Entire width anf height of the Forms 3)Sixe of elements to the overall size of the form 4)Use seperate table cell for each control 5)Avoid enabling the nowrap property in table 6)Avoid Secify the align property table

Upload file to server using javsvcript in Asp.net

1)Add Datagrid to a page use Item template 2)Add inline frame in a page 3)Upload.aspx page contain a file control going upload file into server 4)gridupload .aspx on rowdatabound call javascript function browserup1() 5)browserup1() internally call file control & upload file to a server gridupload.aspx
<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> <script type="text/javascript" language="javascript"> function Browseupl() { var ifUpload; var confirmUpload; ifUpload = ifu.document.form1; ifUpload.myFile.click(); // confirmUpload = confirm ("You are about to upload the file " + ifUpload.myFile.value + " to the server. Do you agree to Upload?"); // if (confirmUpload) // { ifUpload.btnSubmit.click(); // } } </script> </head> <body> <form id="form1" runat="server"> <div> <iframe src="Upload.aspx" frameborder="1" id="ifu" name="ifu" style="display:none;"></iframe> <asp:GridView ID="grdview" runat="server" AutoGenerateColumns="false" OnRowDataBound="grdview_RowDataBound"> <Columns> <asp:BoundField DataField="TntCode" HeaderText="Tenant Code" /> <asp:BoundField DataField="TntName" HeaderText="Tenant Name" /> <asp:BoundField DataField="FrmDt" HeaderText="From Date" /> <asp:BoundField DataField="ToDt" HeaderText="To Date" /> <asp:TemplateField> <ItemTemplate> <asp:ImageButton ID="btnimg" runat="server" CommandName="UPLOAD" ImageUrl="Images/upload_file_icon.gif" /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </div> <div> </div> </form> </body> </html>
gridupload.cs
public partial class gridupload : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Bindgrid(); //grdview.Attributes.Add("onclick", "Browseupl();"); } } private void Bindgrid() { DataTable dt = new DataTable(); DataRow dr; DataColumn dc; dc = new DataColumn("TntCode"); dt.Columns.Add(dc); dc = new DataColumn("TntName"); dt.Columns.Add(dc); dc = new DataColumn("FrmDt"); dt.Columns.Add(dc); dc = new DataColumn("ToDt"); dt.Columns.Add(dc); dr = dt.NewRow(); dr["TntCode"] = "123456"; dr["TntName"] = "Jhon"; dr["FrmDt"] = "06/10/2008"; dr["ToDt"] = "09/10/2008"; dt.Rows.Add(dr); dr = dt.NewRow(); dr["TntCode"] = "452130"; dr["TntName"] = "Peter"; dr["FrmDt"] = "08/10/2008"; dr["ToDt"] = "09/10/2008"; dt.Rows.Add(dr); dr = dt.NewRow(); dr["TntCode"] = "452045"; dr["TntName"] = "James"; dr["FrmDt"] = "04/10/2008"; dr["ToDt"] = "09/10/2008"; dt.Rows.Add(dr); dr = dt.NewRow(); dr["TntCode"] = "785245"; dr["TntName"] = "Ricky"; dr["FrmDt"] = "02/10/2008"; dr["ToDt"] = "09/10/2008"; dt.Rows.Add(dr); dr = dt.NewRow(); dr["TntCode"] = "742569"; dr["TntName"] = "Martin"; dr["FrmDt"] = "07/10/2008"; dr["ToDt"] = "09/10/2008"; dt.Rows.Add(dr); dr = dt.NewRow(); dr["TntCode"] = "124568"; dr["TntName"] = "Bill"; dr["FrmDt"] = "03/10/2008"; dr["ToDt"] = "09/10/2008"; dt.Rows.Add(dr); grdview.DataSource = dt; grdview.DataBind(); } protected void grdview_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[4].Attributes.Add("onclick", "Browseupl();"); } } } }
Upload.aspx
<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> <script type="text/javascript"> function SubmitForm() { // Simply, submit the form document.form1.submit (); } </script> </head> <body> <form id="form1" runat="server"> <div> <input type="file" runat="server" id="myFile" name="myFile" style="visibility:hidden;" /> <input type="button" runat="server" id="btnSubmit" name="btnSubmit" onclick="javascript:SubmitForm();" style="visibility:hidden;" /> <br /><asp:Label ID="lblMsg" runat="server" ForeColor="red" Font-Size="Medium" Font-Bold="true"></asp:Label> </div> </form> </body> </html>

Difference Between .Net & Java

Java
    1. Java is developed by Sun Microsystems
      Java is a light weight language and can be run on almost all the OS(it require less hardware)
      Java you need to confirm it that all the objects are destroyed before application quits.
      Java has no standard tool is available. Although, many third party IDEs are available
      Java is a programming language designed to be run on many different platforms, and so uses a common language which has to be compiled and run on different platforms (eg. windows, mac and linux).Any OS which is able to install JVMJava can be used to write programs for many different operating systems
      Java interface, a null object reference maps to the VT_NULL VARIANT value
      Java interface, all failure HRESULTs from the underlying COM interface are reported by throwing a com.ca.openroad.COMException containing that HRESULT value
  • .NET
    1. .Net is developed by Microsoft Corporation
      .Net needs a very heavy framework to be installed which have higher Hardware requirements too compared to Java
      .Net garbage collector runs at a certain interval and see is there is any memory occupied by anyobject whose parent is now finished processing (for eg. you closed an application), in this casethe garbage collector automatically removes the reference of that object and free up the memory
      .Net a standard development IDE is available that is Microsoft Visual Studio
      .NET, takes on a different approach, by allowing you to program in any language you choose,but has compilers for many different languages that generates a platform specific code (i.e.Microsoft or Windows).
       .NET can be used to make any programming language into a Windows program.NET COM interoperability layer maps null .NET object references to VT_EMPTY. VT_NULLis mapped to a special object type of class “System.DBNull”.
      .NET COM interoperability layer does something similar, using theInteropServices.COMException class. However, it uses that exception class only as a lastresort. If there is already a .NET exception class that reasonably represents the meaning of aparticular HRESULT, the interoperability layer throws that .NET exception instead of a COMException.
  • State Managment In Asp.net 2.0

    State Management: It maintain the information about the client towards the server is called State Management They are 2 Type 1) Client side State Management : It Store Information at client Computer by embedding information in the Web page I)View State:It use track value of the control .Stores information in hidden field II)Control State:It use in custom control to run view state properly. III)Hidden fileds:It is like a View State.It store information in Html Form IV)Cookies:It useto store state data that must avialiable on multiple pages.It stores state in Browser V)Query String :I t is use send email or instant Message state data with url .It stored data in URL 2) Server side State Managemnent:It store information at server side.Sharing information between web pages without sending data to client I) Session State: The Information available to all pages by logged user during single visit II) Application State: The information is available to all pages regardless of user Note :Session state & Application state are lost when apllication retart to presit use profile propertires

    SqlServer Database BackUp and Restore

    1) Copy 2 files. from SouceSystem Databasename.mdf , Database.ldf from installed sql server folder (path:c:\program files]microsoftSql server\Data\datbasname.mdf) 2) Create a Database in Destination system . 3) Past 2 file in installed sql server location (path:c:\program files]microsoftSql server\Data\datbasname.mdf) 4) Right click on destination database then click to attach datbase/files 5) Select appropriate databasename. mdf file Note:Assume sql server installed in C Drive .Path can vary

    Calling Server side Event handler function Uisng Ajax Update pannel

    1)Add Script manger to a page 2)Add Update panel in your page 3)Add any Server side standard Control . 4)In update panel call trigger tag .Inside trigger tag call asp:AysncPostBackTrigger control tag 5)Provide control id & eventname in above tag 6)Example below is assign Textbox value on buttin click
    pseduocode aspx code //Asume one button control id="bttnAjax" and one textbox in content template of update pannel id=txtAjax"
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" >
    <Triggers >
    <asp:AsyncPostBackTrigger ControlID="bttnAjax" EventName="click"/>
    </Triggers>
    <ContentTemplate>
    <asp:TextBox ID="txtAjax" runat ="server"/>
    </ContentTemplate>
    </asp:UpdatePanel>
    
    Code Behind
    protected void bttnAjax_Click(object sender, EventArgs e)
    
    {
    
    txtAjax.Text="Welcome To Ajax World "
    
    }
    
    
    
    
    
    
    
    

    Calling code behind function using Ajax

    1)Drag scriptmanger in your web page add attribute EnablePageMethods="true" 2)Create functions in javascript section (method name are similar example)       I)CallPageMethod()      II)CallParmeterPageMethod()      III)onSucceeded(result,userContext,MethodName)      IV))OnFailed(error,user) 3)Create static and return string function in Code behind (method name are similar example)     I)MyFirstPageMethod() add attribute [System.Web.Service.WebMethod()]     II)MyFirstParameterPageMehtod() add attribute[System.web.Service.WebMethod()] 4)Call javascript function on input button callPagemethod use event onclick
    script code
    function  CallPageMethod()
    {
    debugger;
    PageMethods.MyFirstPageMethod(onSucceeded,onFailed);
    
    }
    function  CallParametersPageMethod()
    {
    debugger;
    PageMethods.MyFirstParameterPageMethod("This is a Demo",onSucceeded,onFailed);
    
    }
    
    function onSucceeded(result,userContext,methodName)
    {
    function CallPageMethod()
    {;
    $get('div1').innerText=result;
    }
    function onFailed(error,user)
    {
    debugger;
    alert("An error occurred");
    }
    code behind code [System.Web.Services.WebMethod()] public static string MyFirstPageMethod() { return "Welcome to Ajaax"; }       [System.Web.Services.WebMethod()] public static string MyFirstParameterPageMethod(string sVal) { return "Welcome To ajax world value passed is" + sVal ; }

    Reterving & assigning values of Server control using javascript

    1)Create a function in javascript section of web page 2)Using document object call appropriate control id to retrive & assign value 3)Both control should be server control . 4)Call javascript function using Clientscript.RegisterStartupscript()
    pseudo code Javascript function fun1() { //Assume one Dropdown & TextBox var s = document.getElementById("ddllist").Value;//or .innerText (to get all value in ddl) document.getElementById("txtUser").Value=s//or .innerText; } Server Side Code //call in any function of server side code ClientScript.RegisterScript(this.getType(),"key1","fun1",True);

    Differencce between .net 2.0 ,3.0,3.5

    .NET 2.0 CLR VERSION 2.0 FRMEWORK LIBRARIES : .NETfx 2.0 LANGUAGE : C# 2.0 VB 8.0 • A new hosting API for native applications wishing to host an instance of the .NET runtime • Full 64-bit support for both the x64 and the IA64 hardware platforms. • Language support for Generics built directly into the .NET CLR. • Many additional and improved ASP.NET web controls. • New data controls with declarative data binding. • New personalization features for ASP.NET, such as support for themes, skins and webparts. .NET 3.0 CLR VERSION 2.0 FRMEWORK LIBRARIES : .NETfx 3.0 LANGUAGE : C# 2.0 VB 8.0 • Windows Presentation Foundation (WPF), formerly code-named Avalon; a new user interface subsystem and API based on XML and vector graphics, which will make use of 3D computer graphics hardware and Direct3D technologies. • Windows Communication Foundation (WCF), formerly code-named Indigo; a service-oriented messaging system which allows programs to interoperate locally or remotely similar to web services. • Windows Workflow Foundation (WWF) allows for building of task automation and integrated transactions using workflows. • Windows CardSpace (WCS), formerly code-named InfoCard; a software component which securely stores a person's digital identities and provides a unified interface for choosing the identity for a particular transaction, such as logging in to a website. .NET 3.5 CLR VERSION 2.0 FRMEWORK LIBRARIES : .NETfx 3.5 LANGUAGE : C# 3.0 VB 9.0 .NET 2.0 contains CLR.WINFORMS,ASPNET .NET 3.0 contains complete .net 2.o and WCF,WPF,WF,CARD SPACE .NET 3.5 contains complete .net 3.0 and LINQ , AJAX langauage integrty query (LINQ): it is microsoft .net framwork component adds data native querying capabilities to .net languages using systnax reminiscent of sql

    Get Cursor position in Asp.net

    1)Add Refernce of System.windows.form 2)using System.Windows.Form 3) Call Cursor object
    puesdo code cursor.postion.x //To retrive x cordinate cusor.postion.y//To reterive y

    Creating Folder in root or parent of Web application using asp.net

    1)Using namespace System.io 2) create folder in root directory specify location in Server.mappath(".") assign variable to string variable (or) Create a folder in parent directory .use Server.mappath("..") assign varaiable to string variable .
    (In web application folder suppose there are 2 folder i.e folder 2 is nest inside folder1 .I
    want create another nest folder3 in folder1 .Folder 1 is parent folder )
    3) Call a CreateDirectory method from Directory class specfy the path pseduo code(c# code) string path =Server.mappath("..") //reterive parent directory path Directory .createDirectory(path +"/Emplyoee" +"NewFolder") // here Employee is folder3 newfolder is nested inside Employeee nest folder of parent folder(web application folder)

    Connecting Web parts using Filter in MOSS

    step to connect web part Assume :Creation of list should known(list nothing but webpart in share point) 1)Click On the Site action Tab on the site and select Edit page 2)Add web part to desired location Right or Left 3)The web page dialogue is open select appropriate list or libaries web part Assume 2 list contain same colum in each list i)Employee list web part contain (eno) as one coloum ii)Employeedetails list web part contain (eno) as one coloum 4)Select this 2 approproiate web parts from the dialog 5)Select employeedetails webparts click on edit button right top corner of web parts 6)In popup window select connection tab -> select get sort/filter from popup-> ->select appropriate web part example employee web part 7) Configuration popup window is open ed select coloum in employee(primary web part) i.e (eno) coloum in employee eb part 8) Select (eno) Coloum from employeedetails (secondary web part or child) then click finish 9) Then Click on exit mode right top corner below web site action web part 10)You will see radio button left corner of a employee web part

    Getting parameter value from store procedure using Enterprise library

    1)Create object of Database class using dbfactory class and provide connectionstring in constructer 2)Create object DbCommand by calling the GetstoreProc... method from Database class object 3) Call AddInparm..... methods from database class object 4)To Reterive value from a parameter call a getParameter method from database class object convert to corresponding datatype
    example bool succes=Convert.ToBoolean( objectDabase. getParmeterobjectCommand,"@statuts")