marktoth
asked on
javascript buton click
I have a web modal dialog box that is retuning an argument to its parent window. The return value is a stateabbreviation. I iterate through a dropdownlist in javascript and select the appropriate state, then simulate a button click to post back the page. That all works fine and the page is posted back and my event handler for the button fires.
In the event handler I get data from the database and fill a grid view with data. The problem is the grid view DOES NOT update when the page is returned to the client. Below is the javascript code. I have put a break point in the event handler for the button and it does fire off the grid view just does not update. I thought that perhaps it was a cacheing issue so added the
<meta http-equiv="Pragma" content="no-cache" />
it the head section of the page.
also below is the code in the event handler for the button. I look at the taxes data table in the GetTaxes() method and all the data is there!
In the event handler I get data from the database and fill a grid view with data. The problem is the grid view DOES NOT update when the page is returned to the client. Below is the javascript code. I have put a break point in the event handler for the button and it does fire off the grid view just does not update. I thought that perhaps it was a cacheing issue so added the
<meta http-equiv="Pragma" content="no-cache" />
it the head section of the page.
also below is the code in the event handler for the button. I look at the taxes data table in the GetTaxes() method and all the data is there!
var rc = new Array(0,0);
function showDialog(taxlevelid)
{
rc = window.showModalDialog("TaxDialog.aspx?lid=" + taxlevelid ,"","center:yes;dialogHeight:300px;dialogWidth:575px;resizable:no;status:yes;");
if(rc[0] != null)
{
//
var sl = document.getElementById("dropDownListState");
for(i=0;i<sl.length;i++)
{
if(sl.options[i].value==rc[1])
{
sl.selectedIndex=i;
break;
}
}
var gtb=document.getElementById("buttonGetTaxes");
gtb.click();
}
}
protected void buttonGetTaxes_Click(object sender, EventArgs e)
{
GetTaxes();
}
private void GetTaxes()
{
DataTable taxes = new DataTable();
using (OracleHelper oHelper = new OracleHelper(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
{
oHelper.QueryCommandType = CommandType.StoredProcedure;
OracleParameter p = new OracleParameter("In_State", dropDownListState.SelectedValue);
oHelper.Parameters.Add(p);
p = new OracleParameter("Out_Cursor", OracleType.Cursor);
p.Direction = ParameterDirection.Output;
oHelper.Parameters.Add(p);
taxes = oHelper.GetDataTable("PKG_TAXLOOKUP_XRXX.READ_TAXES");
}
gridViewTaxTable.DataSource = taxes.DefaultView;
gridViewTaxTable.DataBind();
gridViewTaxTable.SelectedIndex = -1;
}
I believe you need to do the updating at the latest during the Load event. The click event occurs afterwards.
ASKER
ok that does work BUT I just noticed that page_load is called twice. Why would it be called twice?
That is the problem I think. The first call to page_load happens, then the eventhandler is fired. Another postback must happens and page_load is called AGAIN?
That is the problem I think. The first call to page_load happens, then the eventhandler is fired. Another postback must happens and page_load is called AGAIN?
Assuming I'm right about not changing the page after the Load event, any changes you make forces a postback to display your changes.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.