0

I want to use C# code and JavaScript in the same onclientclick event.

<asp:LinkButton ID="lbTest" runat="server" Text='<%#Text%>' 
    OnClientClick='<%#string.Format("passAccessory(\"{0}\");", Eval("Ref"))%>; window.close();' />

But it doesn't work. How to do that?

Thanks.

2
  • 3
    What do you mean by "doesn't work"? What happens? Commented Nov 30, 2010 at 10:48
  • The content of linkbutton is not correct. I doesn't show the variable and close the window, but show the hard text. Commented Nov 30, 2010 at 10:56

2 Answers 2

2

What are you reying to acheive? Do you wnat to call a javascript function which uses some of server side variables and close at the end.

function MyF()
{
    var myvar = '<%= myC#Var %>';
    ....do something

   window.close()

}


<asp:LinkButton ID="lbTest" runat="server"  OnClientClick='MyF()' /> 
Sign up to request clarification or add additional context in comments.

Comments

0

add an OnClientClick and OnClick events. The OnClientClick event will be executed first then the OnClick event.

<asp:LinkButton ID="lbTest" runat="server" OnClientClick="test()" OnClick="lbTest_Click" /> 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.