Geeks With Blogs

News
About Me:
I am a Female SharePoint Developer (a platinum unicorn). I have been working with SharePoint since I attended the Portal University in 2005. I hold a BA in Computer Science from the University of Missouri - Kansas City. I love playing Rockband, organizing user group meetings, working with code, attending events as a speaker or organizer, and having bizarre conversations about geek things with cool people. If you have any comments or questions fill out the contact form and I will try my best to help.



The Guide of a MOSSLover Becky Isserman's Blog

If you want to show the progress bar please refer back to this post on how to get an AJAX Progress Bar to work with SharePoint: http://www.mosslover.com/archive/2008/04/17/how-i-got-an-ajax-progress-bar-to-work-in.aspx.

For the next step you want to create a Javascript Function in your user control or web part that looks a little bit like this:

<script type="javascript/text" >
HideButtons()

{
           var Button1 = <%= Button1.ClientID %>';
           document.getElementbyId(Button1).style.display="none";

}
</script>

If you wanted to do the same thing in a Web Part, then it would look more like this:
string functionHideButtons = "<script type=\"javascript/text\" >\n";
functionHideButtons += "HideButtons()\n";
functionHideButtons += "{\n";
functionHideButtons += "var Button1 = <%= Button1.ClientID %>';\n";
functionHideButtons +=
"document.getElementbyId(Button1).style.display=\"none\";\n";
functionHideButtons += "}\n";
functionHideButtons += "</script>\n";
writer.Write(functionHideButtons);

If you have a Cancel Button too, then you may want to add two different functions.  So maybe a CancelHide and a EventHide or something relational to whatever event your button click will do.  If you have followed my instructions on how to insert the proper UpdatePanel and UpdateProgress Controls, then all you need to do is add the part to link the Javascript Function to the button click event.

In a Web User Control your code you would add this code just before the /> in your button markup:
ClientOnClickScript="javascript:HideButtons();"

If you are working with a Web Part, instead of adding the above code you would put this piece of code in your Render Method: 
Button1.ClientOnClickScript = "HideButtons()";

If anyone has any questions or comments please feel free to ask them.  If you would like another post on AJAX Controls as related to Web Parts, then I would be more than willing to add another post if someone asks for it.  I am hoping to post within the next week on how to load a page by using a hidden button click and not forgoing any use of threading.

Technorati Tags: ,,,
Posted on Wednesday, April 30, 2008 8:20 PM | Back to top


Comments on this post: Hiding Buttons After Clicking Them and Showing a Progress Bar in AJAX

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © MOSSLover | Powered by: GeeksWithBlogs.net