0

I'd like to know how I could add a jQuery function from the server side. I am doing this for attaching to the onClick event on rad

rbtn_Value.Attributes.Add("onclick", "javascript:onGlobalDiscountTypeChange(this)"); 

that was not the jQuery function, now i need to add the onFocusOut function of jQuery mentioned here http://api.jquery.com/focusout/

I'd like to know how I could do that from server like I am doing for OnClick event?

2
  • Why are you manually binding the click event to a jQuery function? Just write it on the client side. Commented Dec 6, 2013 at 12:39
  • i need to as i have many text boxes and i want to add those all from sever side Commented Dec 6, 2013 at 12:46

2 Answers 2

1

Before rendering the page you add this script into any server_side event

 string script="$(document).ready(function(){$('#"+rbtn_Value.ClientID+"')
   .focusout(function(){functionToExecute})";

 ClientScriptManager.RegisterStartupScript(this.GetType(),"discountFocus",script,true);
Sign up to request clarification or add additional context in comments.

1 Comment

its giving wrror Uncaught SyntaxError: Unexpected end of input
0

Solution:

ScriptManager.RegisterClientScriptBlock(this.Page, GetType(), "onclick", "onGlobalDiscountTypeChange(this); return false;", true);

1 Comment

i dont want onclick, bt jQuery onFacusOut

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.