I seem to manage the same task many times beforehand; but currently I got thoroughly stuck at the simplest thing and it have made mequite irritated
I need to assign javascript to ASP.Net linkbutton (or hyperlink, does not matter) What seems to be easier?
Billion times I did it with code like like that
//lbHeader.Attributes.Add("onclick",
// string.Format("ToggleSelectionPopup('{0}');return false;", panelContainer.ClientID));
But it doesn't work. HTML I get contains javascript:__doPostback (blahblahblah) and ignores my client "onclick" function. Instead it the page goes to postback when I click the button (despite "onclick" function attaches properly in the "view page source" HTML
I tried to apply some tricks and approaches like following
1) to replace LinkButton with Hyperlink - effect still same, page forwards to "NavigateURL" when I click the href.
2) to assign "OnClientClick" properety in the declarative layout - the same effect, page goes to postback anyway and ignores "onclick"
3) to assign "javascript:ToggleSelectionPopup(blahblahblah)" as NavigateURL of the hyperlink and as PostBackURL of the linkButton. Doesn't work either
Neither of tricks helped. What do I do wrong, any ideas?
I just need to get rid of shitty server performance of that control, but how can I do it? Certainly, I can make LiteralControl with " manually, but I'd like not to use such a rough approach.
Help highly appreciated