11.5.05

Attributes property of .Net server controls

I was looking for a way to fire off some javascript when an asp:hyperlink control was pressed. I found the answer here

all server controls have an attributes property, which is where the javascript can be placed, like so:
Hyperlink1.Attributes.Add("onclick", "window.open
('popup.aspx',null,'height=250, width=250,status= no, resizable=
no, scrollbars=no, toolbar=no,location=no,menubar=no ');"
);

This can also be used on the body tag:

bodytag.Attributes.Add("onload", "window.open
('popup.aspx',null,'height=250, width=250,status= no, resizable= no,
scrollbars=no, toolbar=no,location=no,menubar=no ');"
);

No comments: