Scripting using button

  • Thread starter Thread starter stephen
  • Start date Start date
S

stephen

Hi all,

I found a nice piece of code that helps me select a value from a datagrid
(second page) and pass the value to the calling page (first page)... but If
I need multiple values then the script fails, I am not good at scripting,
can someone please help me

this is the code:

<INPUT id=btnFind
onclick="document.getElementById('lbContractNum').innerHTML =
window.showModalDialog('FindContract.aspx?'+document.getElementById('lbContractNum').innerHTML,
'','width=300,height=300');"
type=button size=5 value=Find... name=findContract>

How can pass parameters to get multiple values using the same click event
for eg:

I want to try

<INPUT id=btnFind
onclick="document.getElementById('lbContractNum').innerHTML =
window.showModalDialog('FindContract.aspx?'+document.getElementById('lbContractNum').innerHTML,
document.getElementById('lbContractName').innerHTML =
window.showModalDialog('FindContract.aspx?'+document.getElementById('lbContractName').innerHTML
'','width=300,height=300');"
type=button size=5 value=Find... name=findContract>

I get script errors,

thanks for your help,
Stephen
 
I would try it this way:

<INPUT id=btnFind
onclick="document.getElementById('lbContractNum').innerHTML =

window.showModalDialog('FindContract.aspx?num='+document.getElementById('lbContractNum').innerHTML
+ '&name=' + document.getElementById('lbContractName').innerHTML,
'','width=300,height=300');"
type=button size=5 value=Find... name=findContract>

Basically, you want to separate the values you're passing with a "&"
character. Another thing, you normally pass values like this using the
"page.aspx?arg1=val1&arg2=val2" format, instead of "page.aspx?val1&val2".


Steve C.
MCSD,MCAD,MCSE,MCP+I,CNE,CNA,CCNA
 
Hi Steve,

Thanks for the information but now I am getting new errors:
I have used this code in the rowdatabound, how do i modify this to take 2
values?

protected void dgCustomer_RowDataBound(object sender, GridViewRowEventArgs
e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton myLink = (LinkButton)e.Row.Cells[0].Controls[0];
myLink.OnClientClick = "window.returnValue=" + e.Row.Cells[1].Text +
";window.close();return false;";

}

}
I want to return e.row.cells[2].text
I tried
myLink.OnClientClick = "window.returnValue=" + e.Row.Cells[1].Text +
"window.returnValue=" + e.Row.Cells[2].Text +
";window.close();return false;";


Thanks,
Stephen
 
Back
Top