Tuesday, May 22, 2007 8:51 AM
Hmmm...so I have a LinkButton that I'm adding to my web part. I've got code in my CreateChildControls method that has this line:
lnkExportAll.Attributes.Add("OnClick", "javascript:window.open('http://www.yahoo.com');");
When I run the code with this line, everything is fine. However, I have another method in the web part that will dynamically create a URL based on parameters passed in, so I try to do this:
lnkExportAll.Attributes.Add("OnClick", GetMyURL(true, false));
Don't worry about the true/false values...they just set things in the method. The GetMyURL method just uses a string-builder to build a javascript:window.open(...) type of line and returns it.
The problem though is that when I use my GetMyURL method in the line, which is in the CreateChildControls method, it fails when you run it...it gives one of those wonderful "Error...to troubleshoot Sharepoint, please click this hyperlink that does absolutely nothing of value...".
Interesting...
***EDIT: So I figured out what the issue was...as it always tends to be, it was a stupid mistake: I had an unnecesary call to a method that re-filled a grid with data in my GetMyURL method...but because of where I was calling it in my code, the actual grid hadn't been created yet so it was erroring out. I didn't need it in there anyway, so all is now good.
D