G
Guest
hi folks,
I'm using the .Net framework 1.1 with ASP.net and C#:
this is what I'm trying to do...
I've got a repeater template working that creates a hyperlink with a
javascript function call embedded inside it
when the user clicks on the link, it populates a textbox with a value
specific to that link (i.e a person's ID)...I can make this work in a
standalone browser window, but I'm trying to stuff this functionality at run
time into the repeater's template like so:
<asp:Repeater id="repPersonnel" runat="server">
<HeaderTemplate>
<h1>Returned Names</h1>
</HeaderTemplate>
<ItemTemplate>
<a href='#' onClick="passValue('" +
<%# DataBinder.Eval(Container.DataItem,"file_no") %> +
"');return false" >
<%# DataBinder.Eval(Container.DataItem,"sort_nm") %>
</a>
<p />
</ItemTemplate>
I realize this is a bit opaque but the output should look like this:
<input type="text" id="txtChosenvalue" name="txtChosenvalue" />
<p/>
<a href="" onClick="passValue('1000234');return false">Adams, Fred</a>
<p/>
<a href="" onClick="passValue('2000234');return false">Williams, Barry</a>
the passValue function looks like this:
function passValue(theid)
{
document.getElementById("txtChosenvalue").value=theid;
}
the error I'm getting at run time in the browser window is a Javascript error:
Unterminated string constant
and it's to do with trying to stuff the dynamically returned id as a string
constant into the javascript function call as a parameter, inside the
hyperlink.
the problem is, I can't see how it's unterminated, I've got the return value
safely cradeled between two single quotes like so:
<a href='#' onClick="passValue('" +
<%# DataBinder.Eval(Container.DataItem,"file_no") %> +
"');return false" >
any ideas?
Thanks and regards in advance,
CharlesA
I'm using the .Net framework 1.1 with ASP.net and C#:
this is what I'm trying to do...
I've got a repeater template working that creates a hyperlink with a
javascript function call embedded inside it
when the user clicks on the link, it populates a textbox with a value
specific to that link (i.e a person's ID)...I can make this work in a
standalone browser window, but I'm trying to stuff this functionality at run
time into the repeater's template like so:
<asp:Repeater id="repPersonnel" runat="server">
<HeaderTemplate>
<h1>Returned Names</h1>
</HeaderTemplate>
<ItemTemplate>
<a href='#' onClick="passValue('" +
<%# DataBinder.Eval(Container.DataItem,"file_no") %> +
"');return false" >
<%# DataBinder.Eval(Container.DataItem,"sort_nm") %>
</a>
<p />
</ItemTemplate>
I realize this is a bit opaque but the output should look like this:
<input type="text" id="txtChosenvalue" name="txtChosenvalue" />
<p/>
<a href="" onClick="passValue('1000234');return false">Adams, Fred</a>
<p/>
<a href="" onClick="passValue('2000234');return false">Williams, Barry</a>
the passValue function looks like this:
function passValue(theid)
{
document.getElementById("txtChosenvalue").value=theid;
}
the error I'm getting at run time in the browser window is a Javascript error:
Unterminated string constant
and it's to do with trying to stuff the dynamically returned id as a string
constant into the javascript function call as a parameter, inside the
hyperlink.
the problem is, I can't see how it's unterminated, I've got the return value
safely cradeled between two single quotes like so:
<a href='#' onClick="passValue('" +
<%# DataBinder.Eval(Container.DataItem,"file_no") %> +
"');return false" >
any ideas?
Thanks and regards in advance,
CharlesA