scripting using Button

S

stephen

Hi Steve,

Sorry if you have seen this post before but I cant figure this one out...

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
 
M

Mark Rae [MVP]

Thanks for the information but now I am getting new errors:

There really is no point in saying you're getting (new) errors if you don't
actually tell the group what those (new) errors are...
myLink.OnClientClick = "window.returnValue=" + e.Row.Cells[1].Text +
";window.close();return false;";

Where are you actually opening the window...?
 
S

stephen

Hi Mark,

the original post was like this:
I want to select and return values from a datagrid so I added this line in
the parent page (based on suggestion from Steve, a MVP)
<INPUT id=btnFindContName
onclick="document.getElementById('blbContractNumber').innerHTML =
window.showModalDialog('FindCustomer-1.aspx?num='+document.getElementById('blbContractNumber').innerHTML
+ '&name=' +
document.getElementById('blbContractName').innerHTML,'','width=300,height=300');"
type=button size=5 value=Find... name=findContractName>

I wanted mutliple values to be sent across from the child
(FindCustomer.aspx) page and have this in the GridView_RowDataBound Event

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.returnValue=" + e.Row.Cells[2].Text +
";window.close();return false;";
}
}

Now I get script errors when I click the parent page's button its giving me
http://localhost:1679/FindCustomer.aspx?num=&name=
and ';' expected
and when I select from a datagrid it open a brand new window and display
with page cannot be displayed.

hope I make sense,
Thanks for your help,
Stephen



Mark Rae said:
Thanks for the information but now I am getting new errors:

There really is no point in saying you're getting (new) errors if you
don't actually tell the group what those (new) errors are...
myLink.OnClientClick = "window.returnValue=" + e.Row.Cells[1].Text +
";window.close();return false;";

Where are you actually opening the window...?
 
S

Steve

It looks like the window.returnValue property returns only a single
value, and is only used in combination with modal dialogs, which can
only return a single value.

Using the modal dialog method, the only way to *effectively* return two
values is to concatenate both values, but separated with a "---" or some
other character. Then when your dialog returns, separate the two values
again. It's not the most elegant design, but it's the only way when
you're using a modal dialog.

What about this code:


<INPUT id=btnFindContName
onclick="document.getElementById('blbContractNumber').innerHTML =
window.showModalDialog('FindCustomer-1.aspx?'+document.getElementById('blbContractNumber').innerHTML

+ '---' +
document.getElementById('blbContractName').innerHTML,'','width=300,height=300');"

type=button size=5 value=Find... name=findContractName>


This should get the two values returned (as one value). Just split the
values in your dgCustomer_RowDataBound() sub before you , and you should
be good to go.


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

Mark Rae [MVP]

It looks like the window.returnValue property returns only a single value,
and is only used in combination with modal dialogs, which can only return
a single value.

Yes but, like all JavaScript variables, the returnValue is a variant...
Using the modal dialog method, the only way to *effectively* return two
values is to concatenate both values, but separated with a "---" or some
other character.

I just use an array...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top