Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need assistance with returning a value

Status
Not open for further replies.

linuxjr

Programmer
Jun 2, 2001
135
0
0
US
I have two pages page1.aspx and page2.aspx. Page1 opens up page2 in a popup window. Page2 has a datagrid with a button column which is select. I have this in my selectedindexchanged:
Code:
DataGridItem dgi = dtgEQ.SelectedItem;
Response.Write(@"<script language=JavaScript>opener.document.frmWO.txtEqID.value = " + dgi.Cells[1].Text +";</script>");

Anyways dgi.Cells[1].Text is returning the correct value that I'm trying to pass back to page1. The problem I am having is when I send the value to page1 it comes up differently. Example Cells[1] = 123-45678 but when it goes to page1 it returns as -8888. I am pretty stumped and figured an extra pair of eyes might help me find the problem. Any tips or suggestions will be appreciated. Have a great day.
 
Response.Write(@"<script language=JavaScript>opener.document.frmWO.txtEqID.value = '" + JSEncode(dgi.Cells[1].Text) +"';</script>");

Don't forget the single quotes above.


Public Function JSEncode(ByVal s As String) As String
s = Replace(s, "\", "\\")
s = Replace(s, "'", "\'")
s = Replace(s, """", "\""")
s = Replace(s, Chr(10), "\n")
s = Replace(s, Chr(13), "\r")
Return s
End Function
 
RTomes,

Thank you so much. I knew an extra pair of eyes would help me catch something so simple. That will teach me to program with a few hours of sleep. Have yourself a great day/night.
 
Also, don't use Response.Write for anything apart from testing.

If you are wanting to add javascript to a page there are other ways to do it such as Page.RegisterClientScriptBlock and Page.RegisterStartupScript.

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
ca8msm,
Thank you for the tip. I have actually changed it into a function that uses Page.RegisterClientScriptBlock and Page.RegisterStartupScript. At the time of my posting I was just trying to see if it was possible to include the javascript to my select button. Have yourself a great day.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top