exp1
1.Add one image button in datagrid ,and code the javascript to pop up a model window .
<FooterTemplate>
<IMG style="CURSOR: hand" οnclick=javascript:ShowReference(); src="<%=Request.ApplicationPath%>/images/reference.gif">
</FooterTemplate>
<script language="javascript">
function ShowReference(){
//get the skuid from the modaldialog and refresh this page.
var SKU = window.showModalDialog('<%=Request.ApplicationPath%>/OM/FrmSKUReference.aspx', window.document, "dialogWidth:600px;dialogHeight:700px;");
if(SKU.length != null)
{
window.location.href('<%=Request.ApplicationPath%>/OM/FrmOrderItems.aspx');
}
}
</script>
2.in Model window get what u select in DataGrid
aspx:
<!add a hidden var to save the return value.>
<INPUT id="hdCloseWnd" type="hidden" name="hdCloseWnd" runat="server">
<ItemTemplate>
<!add a radiobutton >
<hlcontrols:radiobutton id="rdbProduct" AutoEventWireup="true" AutoPostBack=true text='<%#DataBinder.Eval(Container.DataItem,"ProductSKU").ToString().Trim()%>' runat="Server" onCheckedChanged="Radio_Clicked">
</hlcontrols:radiobutton>
</ItemTemplate>
add javascript ,close the window after getting what u select
<script language="javascript" type="text/javascript"> //update from here //this script block is to set the return value of this search window with the chosen SKU id. var closeWnd = document.Form1.hdCloseWnd; window.returnValue = document.Form1.hdCloseWnd.value; if(closeWnd!=null && closeWnd.value.length > 0) { window.close(); } //update end here </script> <script language="javascript">
//this script block is to set the return value of this search window with the chosen SKU id.
var closeWnd = document.Form1.hdCloseWnd;
window.returnValue = document.Form1.hdCloseWnd.value;
if(closeWnd!=null && closeWnd.value.length > 0)
{
window.close();
}
</script>
cs:
protected void Radio_Clicked(object source, EventArgs e)
{
Herbalife.WebControls.RadioButton rbt = source as Herbalife.WebControls.RadioButton;
Session[SessionKey.SearchCriteriaVO] = null;
Session["SKUid"] = rbt.Text.Trim();
hdCloseWnd.Value = rbt.Text.Trim();
}
3 .In Main WIndow Add some code to get the seesion value when bounding the datagrid
cs:
private void InitializeComponent()
{
this.dgOrderItem.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgOrderItem_ItemCommand);
this.dgOrderItem.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dgOrderItem_ItemDataBound);
this.Load += new System.EventHandler(this.Page_Load);
}
private void dgOrderItem_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Footer)
{
Herbalife.WebControls.TextBox txtNSKU = e.Item.FindControl("txtNSKU") as Herbalife.WebControls.TextBox;
txtNSKU.Text = (string) Session["SKUid"];
Session.Remove("SKUid");
}
}
exp2
Sub WIndow :
aspx:
protected System.Web.UI.HtmlControls.HtmlInputHidden hdCloseWnd;
<script language="javascript" type="text/javascript"> var closeWnd = document.Form1.hdCloseWnd; window.returnValue = document.Form1.hdCloseWnd.value; if(closeWnd!=null && closeWnd.value.length > 0){ window.close(); } </script><script language="javascript" type="text/javascript"> var closeWnd = document.Form1.hdCloseWnd; window.returnValue = document.Form1.hdCloseWnd.value; if(closeWnd!=null && closeWnd.value.length > 0){ window.close(); } </script><script language="javascript" type="text/javascript"> var closeWnd = document.Form1.hdCloseWnd; window.returnValue = document.Form1.hdCloseWnd.value; if(closeWnd!=null && closeWnd.value.length > 0){ window.close(); } </script><script language="javascript">
var closeWnd = document.Form1.hdCloseWnd;
window.returnValue = document.Form1.hdCloseWnd.value;
if(closeWnd!=null && closeWnd.value.length > 0){
window.close();
}
</script>
cs:
protected void Radio_Clicked(object source, EventArgs e)
{
Herbalife.WebControls.RadioButton rbt = source as Herbalife.WebControls.RadioButton;
Session[SessionKey.SearchCriteriaVO] = null;
Session[SessionKey.CustomerID] = rbt.Text.Trim();
hdCloseWnd.Value = rbt.Text.Trim();
}
Main Window:
aspx:
<script language="javascript">
function ShowSearchCust(){
cusID = window.showModalDialog('<%=Request.ApplicationPath%>/OM/FrmSearchCust.aspx', window.document, "dialogWidth:500px;dialogHeight:500px;");
txt = document.getElementById("ucHerbalifeIDControl_txtCustomerID");
if(cusID.length >0)
{
txt.value = cusID;
}
}
</script>
cs:
protected Herbalife.WebControls.ImageButton imglookup;
private void Page_Load(object sender, System.EventArgs e)
{
imglookup.Attributes.Add("onclick","javascript:ShowSearchCust();");
}<script language="javascript" type="text/javascript"> function ShowSearchCust(){ cusID = window.showModalDialog('<%=Request.ApplicationPath%>/OM/FrmSearchCust.aspx', window.document, "dialogWidth:500px;dialogHeight:500px;"); txt = document.getElementById("ucHerbalifeIDControl_txtCustomerID"); if(cusID.length >0) { txt.value = cusID; } } </script>
<script language="javascript" type="text/javascript"> //update from here //this script block is to set the return value of this search window with the chosen SKU id. var closeWnd = document.Form1.hdCloseWnd; window.returnValue = document.Form1.hdCloseWnd.value; if(closeWnd!=null && closeWnd.value.length > 0) { window.close(); } //update end here </script><script language="javascript" type="text/javascript"> function ShowReference(){ //update from here //get the skuid from the modaldialog and refresh this page. var SKU = window.showModalDialog('<%=Request.ApplicationPath%>/OM/FrmSKUReference.aspx', window.document, "dialogWidth:600px;dialogHeight:700px;"); //window.open('<%=Request.ApplicationPath%>/OM/FrmSKUReference.aspx',"",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=800,height=450,left=100,top=100') //txt = document.getElementById("txtNSKU"); if(SKU.length != null) { window.location.href('<%=Request.ApplicationPath%>/OM/FrmOrderItems.aspx'); } //update end here } function focusOnAddButton(object) { //alert(object.id); // var e = event.srcElement; var k = event.keyCode; if (k == 9) { } if (k == 13) { var addCtrl = object.parentElement.parentElement.children[11].children[0]; addCtrl.click(); event.cancelBubble = true; event.returnValue = false; } } </script>