TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Cally K
960
507
15.5k
Adding a Javascript function from code-behind in Page_Load()
Feb 4 2019 12:15 AM
HI,
Why must we add Javascript function from code behind only at the Page_load function
public
partial
class
WebForm5 : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
//this works
TextBox1.Attributes.Add(
"onkeydown"
,
"javascript:alert('keydown')"
);
//TextBox1.Attributes.Add("onchange", "javascript:alert('change')");
}
protected
void
TextBox1_TextChanged(
object
sender, EventArgs e)
{
//this does not
TextBox1.Attributes.Add(
"OnKeyDown"
,
"alert('Hello')"
);
//TextBox1.Attributes.Add("onkeydown", "javascript:alert(this);");
}
}
The first example added to the Page_Load() works whereas the second one does not
Reply
Answers (
7
)
store procedure ?
can i transfer data from one page to another without saving