By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,317 Members | 1,312 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,317 IT Pros & Developers. It's quick & easy.

Referece DB Values in JavaScript

P: n/a
I have an ASP.NET 2.0 application that presents a gridview of the rows in a
table and in one of the fields (columns) I have a button I want to use to
fire a javascript function to open a new window and pass a url with some
query strings. I am not sure of the sysntax in the javascript function to
refer to the database values for that row? In ASP, I use code like -
DataBinder.Eval(Container.DataItem,"id") - but how do I do that in a
javascript function?

Wayne
Nov 27 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
VK

Wayne Wengert wrote:
I have an ASP.NET 2.0 application that presents a gridview of the rows in a
table and in one of the fields (columns) I have a button I want to use to
fire a javascript function to open a new window and pass a url with some
query strings. I am not sure of the sysntax in the javascript function to
refer to the database values for that row? In ASP, I use code like -
DataBinder.Eval(Container.DataItem,"id") - but how do I do that in a
javascript function?


If your page is generated on the server-side anyway why not to preset
all needed info right on the spot - rather than restore it on the
client side?

Say for each new generated row you could add:

....
<td>
<button type="button"
id="<ASP-inserted unique ID>"
onclick="openQueryWindow(<ASP-inserted record ID>)">
Query</button>
</td>
....

Where:
<script type="text/javascript">
function openQueryWindow(q) {
try {
var req = "myDB.asp?" + q;
w = window.open(reg, "wndRequest");
}
catch(e) {
alert("Popup blocker prevents to open the query window");
}
}
</script>

Nov 28 '05 #2

P: n/a
I appreciate that suggestion. I'll give it a try.

Wayne

"VK" <sc**********@yahoo.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...

Wayne Wengert wrote:
I have an ASP.NET 2.0 application that presents a gridview of the rows in
a
table and in one of the fields (columns) I have a button I want to use to
fire a javascript function to open a new window and pass a url with some
query strings. I am not sure of the sysntax in the javascript function to
refer to the database values for that row? In ASP, I use code like -
DataBinder.Eval(Container.DataItem,"id") - but how do I do that in a
javascript function?


If your page is generated on the server-side anyway why not to preset
all needed info right on the spot - rather than restore it on the
client side?

Say for each new generated row you could add:

...
<td>
<button type="button"
id="<ASP-inserted unique ID>"
onclick="openQueryWindow(<ASP-inserted record ID>)">
Query</button>
</td>
...

Where:
<script type="text/javascript">
function openQueryWindow(q) {
try {
var req = "myDB.asp?" + q;
w = window.open(reg, "wndRequest");
}
catch(e) {
alert("Popup blocker prevents to open the query window");
}
}
</script>

Nov 28 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.