I have recently received questions on how to address a Web Control from another page. This is useful when you need to pass values back but do not want to cause a PostBack. A PostBack for anybody who does not know what they are is when an event causes the Web Server to refresh a page from the server to the Client.
The Main Form
Create a Function for instance a Lcik function in JAva and tie this to the Event on a Control for instance a Data Grid Click:
function dgSummary_CellClickHandler(gridName, cellId, button)
{
//Add code to handle your event here.
var row = igtbl_getRowById(cellId); ----- this gets the Row from the PArticular Cell
var grid = igtbl_getGridById(gridName); --- this gets the Grid Handle by Grid Name
var band = row.Band; ============== This gets the Particular Band the Row is in
var col = igtbl_getColumnById(cellId); --- This gets the Proper Column
var Cell = igtbl_getCellById(cellId); ---- This gets the Cell handle - this is not really needed.
//Check to see if it is the PArent BAnd
if (band.Key == "Summary")
{
//Check to see if the Cust ID column is selected for edit.
if(col.Key == "Cust ID")
{
if(row.getCellFromKey("Select Status").getValue() == "C")
{
//Ignore Rows with a Status of C
}
else
{
//Open the Customer Lookup Windows the user can search for the proper Customer
window.open('CustomerLookup.aspx','wCustomer','left=20,top=20,width=900,height=600,toolbar=0,resizable=1'); --- Then Call the new form and create a Handle back to the Form, in this case wCustomer
}
}
}
}
The Second form that was Opened by the Above Call
function dgVendorLookup_AfterRowActivateHandler(gridName, rowId)
{ //Add code to handle your event here.
----------- The below variable is a Pointer back the the Calling Form's Control this will allow you to put a value back to the calling for for use by the calling form. Notice that the 'WebPanel1xdgSummary' is the HTMLElement that we would like to reference from the calling form;
var objOtherGridRow = window.opener.igtbl_getActiveRow('WebPanel1xdgSummary'); //.igpnl_getPanelById('WebPanel1');
if (objOtherGridRow)
{
//Get Active Row On Current Page
var objLocalGridRow = igtbl_getRowById(rowId);
if (objLocalGridRow)
{
//Push Local Row Cells To Corresponding Other Page's Row Cells
objOtherGridRow.getCellFromKey("VendorID").setValue(objLocalGridRow.getCellFromKey("Vendor ID").getValue());
}
}
window.close();}
I hope you found this useful. Using this type of technique will allow you as the developer to always address an HTML or Web Control element from another form. Now this particular Javascript is using a datagrid but if you where using a regular html element you can address those using the same method but you would have to use he html UI element function in javascript to get the handle back to that element.