I’m using ASP Master pages, and I would like to add an “onkeypress” event handler to the <body> in the Master page, but only for a single page.
How do I do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would add a public property to the MasterPage, something like
BodyOnKeyPress. Then set the OnKeyPress attribute of the body tag in the MasterPage’s PreRender event. Client pages just need to set this property before the Master’s PreRender event fires.This is air code, as I don’t have a project to test on. But it should be something like this:
MasterPage Markup:
MasterPage CodeBehind: