Set the event from codebehind:
lbnQuery.Attributes.Add("onclick", "myJavaScriptFunc(" +
CSharpFuncReturnsString() + ");");
If the CSharpFuncReturnsString returns a string that contains something
that isn't a number, you have to put apostrophes around the value. And
if the value can contain apostrophes or backslashes, you have to escape
them by replacing \ with \\ and ' with \':
lbnQuery.Attributes.Add("onclick", "myJavaScriptFunc('" +
CSharpFuncReturnsString().Replace("\\", "\\\\").Replace("'", "\\'") +
"');");
rockdale wrote:
> Hi, All:
>
> How can I achieve this?
>
> I have a Function in JavaScript and this function requires an argument
> which retruns from a backend C# function.
>
> I tried the following, but keep getting error "CS1525: Invalid
> expression term '<' "
>
> I remeber we can do something like this in ASP. ?
>
> <asp:linkbutton id="lbnQuery"
> onClick="myJavaScriptFunc(<%=CSharpFuncReturnsStri ng()%>)"
> CssClass="NormalLinkSmall" runat="server" Text="Query"
> BorderStyle="none"></asp:linkbutton>
>
> Thanks for your help
> -Rockdale
>
|