Showing context menu in the ultrawebgrid using javacript.
step1:
Create ultrawebgrid with Rowselection.(if not choose selected row property getActiveRow method will not work)
step2:
create web menu with property setting of Popupmenu.
step3:
Calling showmenu function from gridcell click of ultrawebgrid.
step4:
function showmenu(objGrid,objGridid,button)
{
var grid = igtbl_getGridById(objGrid);
if(grid.getActiveRow()!=null)
{
if(button==2)
{
igmenu_showMenu('uwmContextmenu',event);
return true;
}
}
else
{
alert("Please select atleast one row");
return false;
}
}
Sharing knowledge in Project, Program, Portfolio Innovation Management (PPIM) and various Technology.
Friday, October 23, 2009
opening Infragistics webdialogwindow using javascript.
opening Infragistics webdialogwindow using javascript.
var dialogObject = $find("WebDialogWindowSchedule");
dialogObject.get_contentPane().set_contentUrl(TargetURL);
dialogObject._header.setCaptionText("Welcome");
dialogObject.show();
In our project we have to give option like. when ever click on the context menu.
have to show the webdialog window.
While loading have to hide the webdialogwindow. only when we click on the context menu
have to show the dialog. for that have to make width and height 0. when we click on the
context menu have to assign the widht and height.
var dialogObject = $find("WebDialogWindowSchedule");
dialogObject.get_contentPane().set_contentUrl(TargetURL);
dialogObject._header.setCaptionText("Welcome");
dialogObject.show();
In our project we have to give option like. when ever click on the context menu.
have to show the webdialog window.
While loading have to hide the webdialogwindow. only when we click on the context menu
have to show the dialog. for that have to make width and height 0. when we click on the
context menu have to assign the widht and height.
We have come across some performance issue in the ultrawebgrid.
Please follow the below rules while doing code with infragistics.
1). Don't add dynamic controls in the Initialize row of the ultrawebgrid.
2). Use PreRender event of ultrawebgrid adding dynamic controls.
3). declare all the styles and properties in the code behind.
Explain.
if you declare properties of ultrawebgrid in the aspx. it will take more time to render. so always try to put in the codebehind.
Thursday, October 22, 2009
how to restrict back button using asp.net.
We have come across the problem while clicking on the back button in the browser.
we shouldn't load the page again when we click on the back button.
Below code it will hide the back button. This is also one of the security leavl have to
follow in the transaction pages.
Response.Buffer = true;
Response.CacheControl = "no-cache";
Response.Cache.SetNoStore();
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
we shouldn't load the page again when we click on the back button.
Below code it will hide the back button. This is also one of the security leavl have to
follow in the transaction pages.
Response.Buffer = true;
Response.CacheControl = "no-cache";
Response.Cache.SetNoStore();
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
Tuesday, October 20, 2009
Downcasting in OOPS
Assinging the parent class to child class this is called downcasting.
public class Class1
{
public string getValue()
{
return "sd";
}
}
public class class3 : Class1
{
public string GetValue1()
{
class3 cl =(class3) new Class1();
return cl.getValue();
}
}
public class Class1
{
public string getValue()
{
return "sd";
}
}
public class class3 : Class1
{
public string GetValue1()
{
class3 cl =(class3) new Class1();
return cl.getValue();
}
}
Upcasting in OOPS
assigning the child class to the parent class that is called the Upcasting
public abstract class Class1
{
public string getValue()
{
return "sd";
}
}
public class class3 : Class1
{
public string GetValue1()
{
Class1 SS =new class3();
return SS.getValue();
}
}
public abstract class Class1
{
public string getValue()
{
return "sd";
}
}
public class class3 : Class1
{
public string GetValue1()
{
Class1 SS =new class3();
return SS.getValue();
}
}
Reading and adding controls dynamically for templated Column in ultrawebgrid.
I have come across performance issue when we add the controls in the initialize row of ulrtrawebgrid. so i have decided to move in to prerender controls.
After moving the controls in to prerender performance got increased.
void uwgProduct_PreRender(object sender, EventArgs e)
{
TemplatedColumn col = (TemplatedColumn)uwgProduct.DisplayLayout.Grid.Bands[0].Columns.FromKey("HeaderCheck");
TemplatedColumn colChild = (TemplatedColumn)uwgProduct.DisplayLayout.Grid.Bands[1].Columns.FromKey("ChildCheck");
int rowTotalCount = uwgProduct.Rows.Count;
///Header////
for (int rowcount = 0; rowcount <>
{
CellItem objcellITem = (CellItem)col.CellItems[rowcount];
HtmlInputCheckBox htmlCheck = new HtmlInputCheckBox();
htmlCheck.Attributes.Add("onclick", "selectEachParent(event,this.value)");
htmlCheck.Attributes.Add("id", Convert.ToString(objcellITem.Value));
htmlCheck.Value = Convert.ToString(objcellITem.Value);
objcellITem.Controls.Add(htmlCheck);
}
////Header/////
////Child Display////////
int childTotalCount = colChild.CellItems.Count;
for (int childCount = 0; childCount <>
{
CellItem objcellITem = (CellItem)col.CellItems[rowIndex];
CellItem objcellITemChild = (CellItem)colChild.CellItems[childCount];
HtmlInputCheckBox htmlCheckChild = new HtmlInputCheckBox();
htmlCheckChild.Attributes.Add("onclick", "UnselectParent(event,this.value)");
htmlCheckChild.ID = Convert.ToString(objcellITem.Value) + "_" + Convert.ToString(objcellITemChild.Value);
htmlCheckChild.Value = Convert.ToString(objcellITem.Value) + "_" + Convert.ToString(objcellITemChild.Value);
objcellITemChild.Controls.Add(htmlCheckChild);
}
////End Child Display////////
}
After moving the controls in to prerender performance got increased.
void uwgProduct_PreRender(object sender, EventArgs e)
{
TemplatedColumn col = (TemplatedColumn)uwgProduct.DisplayLayout.Grid.Bands[0].Columns.FromKey("HeaderCheck");
TemplatedColumn colChild = (TemplatedColumn)uwgProduct.DisplayLayout.Grid.Bands[1].Columns.FromKey("ChildCheck");
int rowTotalCount = uwgProduct.Rows.Count;
///Header////
for (int rowcount = 0; rowcount <>
{
CellItem objcellITem = (CellItem)col.CellItems[rowcount];
HtmlInputCheckBox htmlCheck = new HtmlInputCheckBox();
htmlCheck.Attributes.Add("onclick", "selectEachParent(event,this.value)");
htmlCheck.Attributes.Add("id", Convert.ToString(objcellITem.Value));
htmlCheck.Value = Convert.ToString(objcellITem.Value);
objcellITem.Controls.Add(htmlCheck);
}
////Header/////
////Child Display////////
int childTotalCount = colChild.CellItems.Count;
for (int childCount = 0; childCount <>
{
CellItem objcellITem = (CellItem)col.CellItems[rowIndex];
CellItem objcellITemChild = (CellItem)colChild.CellItems[childCount];
HtmlInputCheckBox htmlCheckChild = new HtmlInputCheckBox();
htmlCheckChild.Attributes.Add("onclick", "UnselectParent(event,this.value)");
htmlCheckChild.ID = Convert.ToString(objcellITem.Value) + "_" + Convert.ToString(objcellITemChild.Value);
htmlCheckChild.Value = Convert.ToString(objcellITem.Value) + "_" + Convert.ToString(objcellITemChild.Value);
objcellITemChild.Controls.Add(htmlCheckChild);
}
////End Child Display////////
}
Infragistics WebDataGrid validation.
In our project we need to do validation for webdatagrid using javascript.
var Gkey,GIndex;
function EnterEditModeValidate(objGrid,Obj1Edited)
{
Gkey = Obj1Edited._cell._column._key;
GIndex = Obj1Edited.getCell().get_row()._index;
}
function ExitingEditValidate(sender,evntArgs)
{
//var index=sender.get_columns().get_columnFromKey(Gkey).get_index();
//var value=sender.get_rows().get_row(GIndex).get_cell(index).get_value();
var innT = document.getElementById("wdgProductList_ed0");
var iChars = "!@#$%^&*()+=-[]\\\;,./{}|\":<>?~_";
if(innT!=null)
{
var sValue = innT.children[0].value;
if(Gkey=="ShipAddress")
{
if(sValue=="")
{
alert("Please enter the value");
evntArgs.set_cancel(true);
}
if(sValue.length > 40)
{
alert("Charecters should be below 40");
evntArgs.set_cancel(true);
}
for (var count = 0; count <>
{
if (iChars.indexOf(sValue.charAt(count)) != -1)
{
alert ("Your string has special characters. \nThese are not allowed.");
evntArgs.set_cancel(true);
}
}
}
}
}
var Gkey,GIndex;
function EnterEditModeValidate(objGrid,Obj1Edited)
{
Gkey = Obj1Edited._cell._column._key;
GIndex = Obj1Edited.getCell().get_row()._index;
}
function ExitingEditValidate(sender,evntArgs)
{
//var index=sender.get_columns().get_columnFromKey(Gkey).get_index();
//var value=sender.get_rows().get_row(GIndex).get_cell(index).get_value();
var innT = document.getElementById("wdgProductList_ed0");
var iChars = "!@#$%^&*()+=-[]\\\;,./{}|\":<>?~_";
if(innT!=null)
{
var sValue = innT.children[0].value;
if(Gkey=="ShipAddress")
{
if(sValue=="")
{
alert("Please enter the value");
evntArgs.set_cancel(true);
}
if(sValue.length > 40)
{
alert("Charecters should be below 40");
evntArgs.set_cancel(true);
}
for (var count = 0; count <>
{
if (iChars.indexOf(sValue.charAt(count)) != -1)
{
alert ("Your string has special characters. \nThese are not allowed.");
evntArgs.set_cancel(true);
}
}
}
}
}
Thursday, October 15, 2009
Adding controls in to ultrawebgrid using PreRenderMethod.
TemplatedColumn col = (TemplatedColumn)uwgProduct.DisplayLayout.Grid.Bands[0].Columns.FromKey("HeaderCheck");
int rowTotalCount = uwgProduct.Rows.Count;
for (int rowcount = 0; rowcount < rowTotalCount; rowcount++)
{
CellItem objcellITem = (CellItem)col.CellItems[rowcount];
DropDownList drp = new DropDownList();
drp.Items.Add(new ListItem("test", "ss"));
drp.ID = "dd";
objcellITem.Controls.Add(drp);
}
int rowTotalCount = uwgProduct.Rows.Count;
for (int rowcount = 0; rowcount < rowTotalCount; rowcount++)
{
CellItem objcellITem = (CellItem)col.CellItems[rowcount];
DropDownList drp = new DropDownList();
drp.Items.Add(new ListItem("test", "ss"));
drp.ID = "dd";
objcellITem.Controls.Add(drp);
}
Friday, October 9, 2009
Special Character Validation
var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?~_";
for (var i = 0; i < objGridCellValue.length; i++)
{
if (iChars.indexOf(objGridCellValue.charAt(i)) != -1) {
alert ("Your string has special characters. \nThese are not allowed.");
return false;
}
}
for (var i = 0; i < objGridCellValue.length; i++)
{
if (iChars.indexOf(objGridCellValue.charAt(i)) != -1) {
alert ("Your string has special characters. \nThese are not allowed.");
return false;
}
}
Date Compare Function
function DateFormat(dt)
{
var dtformat = new Date(dt)
return dt.format("MM/dd/yyyy");
}
function DateCompare(fromDt,toDt)
{
var arrFromdt=fromDt.split("/");
var arrTodt=toDt.split("/");
var fromDt=new Date(arrFromdt[2],replaceDt(arrFromdt[0]),replaceDt(arrFromdt[1]));
var toDt=new Date(arrTodt[2],replaceDt(arrTodt[0]),replaceDt(arrTodt[1]));
if(fromDt<=toDt)
{
return "1";
}
else
{
return "0";
}
}
function replaceDt(replaceValue)
{
if(parseInt(replaceValue)<10)
{
return replaceValue.replace('0','');
}
else
{
return replaceValue;
}
}
{
var dtformat = new Date(dt)
return dt.format("MM/dd/yyyy");
}
function DateCompare(fromDt,toDt)
{
var arrFromdt=fromDt.split("/");
var arrTodt=toDt.split("/");
var fromDt=new Date(arrFromdt[2],replaceDt(arrFromdt[0]),replaceDt(arrFromdt[1]));
var toDt=new Date(arrTodt[2],replaceDt(arrTodt[0]),replaceDt(arrTodt[1]));
if(fromDt<=toDt)
{
return "1";
}
else
{
return "0";
}
}
function replaceDt(replaceValue)
{
if(parseInt(replaceValue)<10)
{
return replaceValue.replace('0','');
}
else
{
return replaceValue;
}
}
Friday, August 21, 2009
Asp DataGrid with Editable cell with out Postback using Javascript
This is created for one of my friend. he want's in his project. so i thought of sharing with everyone am writing in my blog.
step 1:
create asp grid control with binding dummy value.
step 2:
<asp:GridView ID="grView" runat="server" AutoGenerateColumns="false"
onprerender="grView_PreRender">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<div id="lblDiv" runat="server">
<asp:Label ID="lblID" runat="server" Text='<%# Eval("Empid") %>'></asp:Label>
</div>
<div id="txtDiv" style="display:none" runat="server">
<asp:TextBox ID="txtID" runat="server" Text='<%# Eval("Empid") %>'></asp:TextBox>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
step 3:
DataTable DT = new DataTable();
DataColumn dc1 = new DataColumn("Empid");
DataColumn dc2 = new DataColumn("Empname");
DataColumn dc3 = new DataColumn("EmpSalary");
DataColumn dc4 = new DataColumn("EmpAddress");
DT.Columns.Add(dc1);
DT.Columns.Add(dc2);
DT.Columns.Add(dc3);
DT.Columns.Add(dc4);
DataRow DR;
for (int i = 0; i <>
{
DR = DT.NewRow();
DR["Empid"] = i.ToString();
DR["Empname"] = "Bala";
DR["Empid"] = "Salary";
DR["Empid"] = "Address";
DT.Rows.Add(DR);
}
grView.DataSource = DT;
grView.DataBind();
step 4:
Calling javascript for the cell through.
protected void grView_PreRender(object sender, EventArgs e)
{
foreach (GridViewRow dr in grView.Rows)
{
Label lbl = (Label)dr.FindControl("lblID");
lbl.ID = "lblID";
lbl.Attributes.Add("onclick", "javascript:lbltoTxt(this)");
TextBox txt = (TextBox)dr.FindControl("txtID");
txt.Attributes.Add("onblur", "javascript:txttoLbl(this)");
}
}
Step 5:
<script language="javascript">
function lbltoTxt(obj)
{
var divtxtObj = document.getElementById(obj.id.replace('lblID', 'txtDiv'));
var txtObj = document.getElementById(obj.id.replace('lblID', 'txtID'));
if (divtxtObj != null)
{
if (divtxtObj.style.display == "none")
{
divtxtObj.style.display = "block";
txtObj.focus();
}
}
var divlblObj = document.getElementById(obj.id.replace('lblID', 'lblDiv'));
if (divlblObj != null)
{
if (divlblObj != null)
{
divlblObj.style.display = "none"
}
}
}
function txttoLbl(obj) {
var divlblObj = document.getElementById(obj.id.replace('txtID', 'lblDiv'));
var lblObj = document.getElementById(obj.id.replace('txtID', 'lblID'));
if (divlblObj != null) {
if (divlblObj.style.display == "none") {
divlblObj.style.display = "block";
lblObj.innerText = obj.value;
}
}
var divtxtObj = document.getElementById(obj.id.replace('txtID', 'txtDiv'));
if (divtxtObj != null) {
if (divtxtObj != null) {
divtxtObj.style.display = "none"
}
}
}
</script>
Wednesday, August 12, 2009
What is the use of "Canvas" Controls?????
Canvas is one of the layout control for the silverlight. This is just like container will contain the controls.
In silverlight wright now we have three layout controls. The layout types are as given below.
1)Canvas.
2)StackPanel.
3)Grid.
My first feel with Silverlight
first of all have to say thanks to microsoft to developing this kind of product.
Let's start learning with next generation technology.
Monday, August 10, 2009
javascript listbox problem
just thought of sharing this info with everyone. I am writing in my blog.
Every one no about list box control in the asp.net controls. I have tried to write javascript for selected value when enabled the multiselection for the control. In this situation am unable to get the selected value index correctly. it's coming differentyly.. post me if you know the answer..
Friday, August 7, 2009
To fire onclick event automatically on page load using Javascript
if(navigator.appName !="Microsoft Internet Explorer")
{
HTMLElement.prototype.click = function()
HTMLElement.prototype.click = function()
{
var evt = this.ownerDocument.createEvent('MouseEvents');
evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
this.dispatchEvent(evt);
}
var evt = this.ownerDocument.createEvent('MouseEvents');
evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
this.dispatchEvent(evt);
}
}
Avoid Special Character using Javascript with Regular Expression
javascript validation for special charcter.
function checkSpecial(obj,objEvent)
{
var specialChar = "^[A-Za-z0-9_]+$" //regular expression defining a 5 digit number
var objVal = obj.value;
var objVallen = obj.value.length;
if (objVal != "")
{
if (objVal.search(specialChar) == -1) //if match failed
{
if (objEvent == "keyup") {
if (objVallen > 1) {
obj.value = objVal.substring(0, parseInt(objVallen) - 1);
}
else {
obj.value = "";
}
}
else {
obj.value = "";
}
alert("Invalid character");
obj.focus();
}
}
}
Monday, July 13, 2009
Fileupload control not working with in updatepanel
I have found the problem, while accessing the fileupload control with in update panel. selected file path get cleared when postback.. i have found one solution for that problem. let me explain the solution with example.
i have used one asp hidden control, using javascript before postback am assigning the path in to hidden control. while accessing server side am getting the path from hidden contrl.
Let's go through the sample.
Aspx Code
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
</asp:ScriptManager>
<asp:UpdatePanel ID="upDate" runat="server">
<ContentTemplate>
<asp:FileUpload ID="fileUpload" runat="server" />
<asp:Button ID="btnSave" runat="server" onclick="btnSave_Click" />
<asp:HiddenField ID="hidFileName" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
Javascript:
function fileUploads(objGetId, objHidId) {
var objfile = document.getElementById(objGetId);
var objhid = document.getElementById(objHidId);
if (objfile != null) {
objhid.value = objfile.value;
}
}
C# Code
protected void Page_Load(object sender, EventArgs e)
{
btnSave.Attributes.Add("onclick", "javascript:fileUploads('fileUpload','"+hidFileName.ClientID+"')");
// string test = fileUpload.FileName;
}
protected void btnSave_Click(object sender, EventArgs e)
{
string test = hidFileName.Value;
}
ExcelDataReader
hi guys, This is one of the best approuch for converting excel in to dataset. I am using this in our project. This exceldatareader will read very faster than any other approach so far.
So that we are using in our project. Its very good approach.. let's download in the below url
http://www.codeplex.com/ExcelDataReader
Then include in your project. Just include in your project as a DLL. Then access all the classes.
Parent Child Display using Asp.net 2.0
I have comeacross some of friends needed this code to create parent and child combination in the webpage.
So thought of sharing them have created sample code for displaying the parent and child combination.
I am using Parent control as a Repeater control and child as a Gridview control.
Please go throgh the example:
Aspx Code:
<asp:Repeater ID="grdMulti" runat="server" OnItemDataBound="grdMulti_RowDataBound">
<ItemTemplate>
<table width="100%" border="1" style="border-style:solid">
<tr>
<td>
<table width="100%">
<tr>
<td>
<img id="imgExpand" runat="server" src="Image/add_up.gif" onclick="javascript:showChild(this)"
style="vertical-align: top" />
<img id="imgCollapse" runat="server" src="Image/del_up.gif" onclick="javascript:showChild(this)"
style="display: none; vertical-align: top" />
</td>
<td>
<asp:Label ID="lblServiceAddress" runat="server" Text='<%# Eval("ServiceId") %>'></asp:Label>
</td>
<td>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("ServiceName") %>'></asp:Label>
</td>
<td>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("ServiceAddress") %>'></asp:Label>
</td>
</tr>
</table>
</td>
</tr>
<tr id="ShowRow" runat="server" style="display:none">
<td>
<table width="100%">
<tr>
<td>
<div id="Show" runat="server" style="display: none">
<asp:GridView ID="grdChild" runat="server" Width="100%">
</asp:GridView>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
Javscript:
<script language="javascript">
function showChild(obj) {
var imgId = obj.id, grdId, grdObj, objImg = document.getElementById(imgId), imgChangeId, imgChangeObj, rowid;
if (obj.id.indexOf('Expand') > 0) {
grdId = obj.id.replace('imgExpand', 'Show');
rowid = obj.id.replace('imgExpand', 'ShowRow');
imgChangeId = obj.id.replace('imgExpand', 'imgCollapse');
imgChangeObj = document.getElementById(imgChangeId);
grdObj = document.getElementById(grdId);
rowobj=document.getElementById(rowid);
if (objImg != null) {
objImg.style.display = 'none'
}
if (grdObj != null) {
grdObj.style.display = 'block'
}
if (imgChangeObj != null) {
imgChangeObj.style.display = 'block';
}
if (rowobj != null) {
rowobj.style.display = 'block';
}
}
else {
grdId = obj.id.replace('imgCollapse', 'Show');
rowid = obj.id.replace('imgExpand', 'ShowRow');
imgChangeId = obj.id.replace('imgCollapse', 'imgExpand');
imgChangeObj = document.getElementById(imgChangeId);
grdObj = document.getElementById(grdId);
rowobj = document.getElementById(rowid);
if (grdObj != null) {
grdObj.style.display = 'none'
}
if (objImg != null) {
objImg.style.display = 'none'
}
if (imgChangeObj != null) {
imgChangeObj.style.display = 'block';
}
if (rowobj != null) {
rowobj.style.display = 'none';
}
}
}
</script>
C#
public partial class MultiGrid : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable DTParent = new DataTable();
DataColumn dc1 = new DataColumn("ServiceId");
DataColumn dc2 = new DataColumn("ServiceName");
DataColumn dc3 = new DataColumn("ServiceAddress");
DTParent.Columns.Add(dc1);
DTParent.Columns.Add(dc2);
DTParent.Columns.Add(dc3);
DataRow DR = null;
for (int i = 0; i <>
{
DR = DTParent.NewRow();
DR[0] = i.ToString();
DR[1] = "bal";
DR[2] = "Address";
DTParent.Rows.Add(DR);
}
grdMulti.DataSource = DTParent;
grdMulti.DataBind();
}
}
protected void grdMulti_RowDataBound(object sender, RepeaterItemEventArgs e)
{
GridView GRDChild = (GridView)e.Item.FindControl("grdChild");
if (GRDChild != null)
{
DataTable DTChild = new DataTable();
DataColumn dc1 = new DataColumn("ServiceId");
DataColumn dc2 = new DataColumn("ServiceName");
DataColumn dc3 = new DataColumn("ServiceAddress");
DTChild.Columns.Add(dc1);
DTChild.Columns.Add(dc2);
DTChild.Columns.Add(dc3);
DataRow DR = null;
for (int i = 0; i <>
{
DR = DTChild.NewRow();
DR[0] = i.ToString();
DR[1] = "bal";
DR[2] = "Address";
DTChild.Rows.Add(DR);
}
GRDChild.DataSource = DTChild;
GRDChild.DataBind();
}
}
}
Subscribe to:
Posts (Atom)