mike55 Posted April 18, 2006 Posted April 18, 2006 Hi all I am looking for code that will prevent the user from clicking on a particular button more than once. I got some C# code that is suppose to work. I converted this code into vb.net: Dim sb As New System.Text.StringBuilder sb.Append("if (typeof(Page_ClientValidate) == 'function') { ") sb.Append("if (Page_ClientValidate() == false) { return false; }} ") sb.Append("this.value = 'Please wait...';") sb.Append("this.disabled = true;") sb.Append(ClientScript.GetPostBackEventReference(Button1)) sb.Append(";") Button1.Attributes.Add("onclick", sb.ToString()) The problem that I am getting is: "Value of type System.Web.UI.WebControl.Button cannot be converted into System.Web.UI.PostBackOptions". I am using the .net 2005 professional environment. Am suggestions for this problem? Mike55. Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
Administrators PlausiblyDamp Posted April 18, 2006 Administrators Posted April 18, 2006 What did the original C# code look like? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mike55 Posted April 18, 2006 Author Posted April 18, 2006 What did the original C# code look like? System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("if (typeof(Page_ClientValidate) == 'function') { "); sb.Append("if (Page_ClientValidate() == false) { return false; }} "); sb.Append("this.value = 'Please wait...';"); sb.Append("this.disabled = true;"); sb.Append(this.Page.GetPostBackEventReference(this.Button1)); sb.Append(";"); this.Button1.Attributes.Add("onclick", sb.ToString()); I had to change the page.getpostbackeventreference to clientscript.getpostbackeventreference as .net 05 kept telling me there was an error. A web site that I came across suggested using the following: System.Threading.Thread.Sleep(2000) However you have no way of knowing how long the sleep will have to be for. Mike55. Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
mike55 Posted April 18, 2006 Author Posted April 18, 2006 It would seem that the solution to my problem is to leave the line: this.page.getpostbackeventreference(this.button1) as it is and not change is to this.clientscript.getpostbackeventreference(this.button1) as .net 05 wants. Mike55. Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.