 |
|
 |
i am new to ajax i have a registartion form with 2 buttons. button1 is in updatepanel with a textbox and button2(submit) is outside updatepanel.
i want button2 diabled on page load and depending on the true / flase condition on button1 click i want button2 to be enabled. how to achieve it
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
 | Thanks  hido2628 | 0:22 27 Aug '08 |
|
|
 |
|
 |
My client still use framework 1.1 and the web solutions are for net 2 or 3. I need this urgent. thanks a lot, i really aprecite this.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I am developing a new server control - CommandClickOnce button based on ClickOnce button. I am Creating credit card information in c# asp.net in 2003. I want to ClickOnceButton.dll(Commandbutton) code in c# Pls give me a CommandButton ClickOnceButton Server Control code.
|
| Sign In·View Thread·PermaLink | 1.00/5 |
|
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
 |
I wanted to use this in an UpdatePanel with an UpdateProgress control but the UpdateProgress control doesnt seem to show after clicking the ClickOnceButton. Is it cause it's not inheriting from the Button control? I created a click once image button that inherited from the ImageButton contral it triggered the UpdateProgress control.
Any ideas? It would be nice if there was already an Ajax control that did this, wouldnt it? 
Iggy
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Does ClickOnceButton able to support same ValidationGroup functionality as found in standard Button control?
|
| Sign In·View Thread·PermaLink | 5.00/5 |
|
|
|
 |
|
 |
I tink that is alot for work for the simple task you want to achieve. You could have simple made the button invisible and make another button that is disabled visible. But make sure that the new button is in the exact place as the old one, which would only take one line of code.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi everyone: I just wanted to ask: what about the "if (typeof(Page_ClientValidate) != 'function' || Page_ClientValidate()){" client script sentences in ASP NET 2.0? is the "Page_ClientValidate" still used? will this work on 2.0?
jportelas
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
|
|
 |
|
 |
This control was exactly what I needed. I had to tweak it slightly to make it work in ASP.NET 2.0 (mainly to remove a couple of references to the deprecated functions or conventions Mybase.page.RegisterHiddenField and Me.OnceClickBtnName).
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Wow, people still read this article? Glad you found it useful I've been meaning to release an updated version, just can never seem to find the time.
~Eric
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I have developed a new server control - PromptClickOnce button based on ClickOnce button. Besides the features of validation and ClickOnce, it integrates a new feature: prompt a confirmation dialog box. When it is clicked, it first validates the page, then popup a dialog to ask user's confirmation before performing ClickOnce. If you need this button, simply add it to ClickOnceButton project, and build new ClickOnceButton assemly. After you add the new assemly to your .NET toolbox, you will see this new server control. Have fun to play with it!
Imports System.ComponentModel Imports System.Web.UI Imports System.Drawing
<ToolboxBitmap(GetType(System.Web.UI.WebControls.Button)), DefaultEvent("Click")> _ Public Class PromptClickOnceButton Inherits System.Web.UI.WebControls.WebControl Implements IPostBackEventHandler
Public Event Click As EventHandler Public Event Command As System.Web.UI.WebControls.CommandEventHandler
Private Const OnceClickBtnName As String = "__onceClickBtn"
<Browsable(True), Category("Behavior")> _ Public Property DisableAfterClick() As Boolean Get Dim o As Object = MyBase.ViewState("DisableAfterClick") Return IIf(IsNothing(o), False, CBool(o)) End Get Set(ByVal Value As Boolean) MyBase.ViewState("DisableAfterClick") = Value End Set End Property
<Browsable(True), Category("Behavior")> _ Public Property CommandName() As String Get Dim o As Object = MyBase.ViewState("CommandName") Return IIf(IsNothing(o), String.Empty, CStr(o)) End Get Set(ByVal Value As String) MyBase.ViewState("CommandName") = Value End Set End Property
<Browsable(True), Category("Behavior")> _ Public Property CommandArgument() As String Get Dim o As Object = MyBase.ViewState("CommandArgument") Return IIf(IsNothing(o), String.Empty, CStr(o)) End Get Set(ByVal Value As String) MyBase.ViewState("CommandArgument") = Value End Set End Property
<Browsable(True), Category("Appearance")> _ Public Property DisabledText() As String Get Dim o As Object = MyBase.ViewState("DisabledText") Return IIf(IsNothing(o), String.Empty, CStr(o)) End Get Set(ByVal Value As String) MyBase.ViewState("DisabledText") = Value End Set End Property
<Browsable(True), Category("Appearance")> _ Public Property Text() As String Get Dim o As Object = MyBase.ViewState("Text") Return IIf(IsNothing(o), "Button", CStr(o)) End Get Set(ByVal Value As String) MyBase.ViewState("Text") = Value End Set End Property
<Browsable(True), Category("Behavior")> _ Public Property CausesValidation() As Boolean Get Dim o As Object = MyBase.ViewState("CausesValidation") Return IIf(IsNothing(o), True, CBool(o)) End Get Set(ByVal Value As Boolean) MyBase.ViewState("CausesValidation") = Value End Set End Property
<Browsable(True), Category("Behavior")> _ Public Property ConfirmBeforeSubmit() As Boolean Get Dim o As Object = MyBase.ViewState("ConfirmBeforeSubmit") Return IIf(IsNothing(o), True, CBool(o)) End Get Set(ByVal Value As Boolean) MyBase.ViewState("ConfirmBeforeSubmit") = Value End Set End Property
<Browsable(True), Category("Appearance")> _ Public Property ConfirmationMessage() As String Get Dim o As Object = MyBase.ViewState("ConfirmationMessage") Return IIf(IsNothing(o), String.Empty, CStr(o)) End Get Set(ByVal Value As String) MyBase.ViewState("ConfirmationMessage") = Value End Set End Property
Public Sub New() MyBase.New(HtmlTextWriterTag.Input) End Sub
<Browsable(False)> _ Friend ReadOnly Property GetClientValidate() As String Get Return "if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); " End Get End Property
<Browsable(False)> _ Friend ReadOnly Property GetClickOnceClientValidate() As String Get Return "if (typeof(Page_ClientValidate) == 'function') { if(Page_ClientValidate()) { " + _ GetClickOnceJavascript + " }} else { " + _ GetClickOnceJavascript + " }" End Get End Property
<Browsable(False)> _ Friend ReadOnly Property GetClickOnceJavascript() As String Get Return "document.getElementsByName('" + Me.OnceClickBtnName + "').item(0).setAttribute('name'," + _ "this.getAttribute('name')); this.disabled = true; " + _ IIf(DisabledText = String.Empty, String.Empty, "this.value = '" + DisabledText + "';") + _ "this.form.submit();" End Get End Property
<Browsable(False)> _ Friend ReadOnly Property GetConfirmJavascript() As String Get Return "return confirm('" + EscapedMessage(ConfirmationMessage) + "');"
End Get End Property
<Browsable(False)> _ Friend ReadOnly Property GetConfirm() As String Get
Return "confirm('" + EscapedMessage(ConfirmationMessage) + "')"
End Get End Property
<Browsable(False)> _ Friend ReadOnly Property GetConfirmReturn() As String Get
Return "if (confirm('" + EscapedMessage(ConfirmationMessage) + "')) " + _ "{ return true;} else {return false;} "
End Get End Property
<Browsable(False)> _ Friend ReadOnly Property GetConfirmClientValidate() As String Get Return "if (typeof(Page_ClientValidate) == 'function') { if(Page_ClientValidate()) { " + _ GetConfirmReturn + " }} else { " + _ GetConfirmReturn + " }" End Get
End Property
<Browsable(False)> _ Friend ReadOnly Property GetConfirmClickOnce() As String Get Return " if( " + GetConfirm + ") { " + _ GetClickOnceJavascript + " } else {return false;}" End Get
End Property
<Browsable(False)> _ Friend ReadOnly Property GetConfirmClickOnceClientValidate() As String Get Return "if (typeof(Page_ClientValidate) == 'function') { if(Page_ClientValidate()) { " + _ GetConfirmClickOnce + " }} else { " + _ GetConfirmClickOnce + " }" End Get End Property
Protected Overrides Sub RenderContents(ByVal writer As HtmlTextWriter) End Sub
Protected Overrides Sub AddAttributesToRender(ByVal writer As HtmlTextWriter) Dim strOnClick As String
If IsNothing(MyBase.Page) Then MyBase.Page.VerifyRenderingInServerForm(Me) End If
writer.AddAttribute(HtmlTextWriterAttribute.Type, "submit") writer.AddAttribute(HtmlTextWriterAttribute.Name, MyBase.UniqueID) writer.AddAttribute(HtmlTextWriterAttribute.Value, Me.Text)
If Not IsNothing(MyBase.Page) And Me.CausesValidation And MyBase.Page.Validators.Count > 0 Then If Me.DisableAfterClick Then If Me.ConfirmBeforeSubmit Then strOnClick = Me.GetConfirmClickOnceClientValidate Else strOnClick = Me.GetClickOnceClientValidate End If Else If Me.ConfirmBeforeSubmit Then strOnClick = Me.GetConfirmClientValidate Else strOnClick = Me.GetClientValidate End If End If If MyBase.Attributes.Count > 0 And Not IsNothing(MyBase.Attributes("onclick")) Then strOnClick = String.Concat(MyBase.Attributes("onclick"), strOnClick) MyBase.Attributes.Remove("onclick") End If
writer.AddAttribute("language", "javascript") writer.AddAttribute(HtmlTextWriterAttribute.Onclick, strOnClick)
ElseIf Me.DisableAfterClick Or Me.ConfirmBeforeSubmit Then If Me.DisableAfterClick Then If Me.ConfirmBeforeSubmit Then strOnClick = Me.GetConfirmClickOnce Else strOnClick = Me.GetClickOnceJavascript End If Else If Me.ConfirmBeforeSubmit Then strOnClick = Me.GetConfirmJavascript End If End If
If MyBase.Attributes.Count > 0 And Not IsNothing(MyBase.Attributes("onclick")) Then strOnClick = String.Concat(MyBase.Attributes("onclick"), strOnClick) MyBase.Attributes.Remove("onclick") End If
writer.AddAttribute("language", "javascript") writer.AddAttribute(HtmlTextWriterAttribute.Onclick, strOnClick) End If
MyBase.AddAttributesToRender(writer)
End Sub
Protected Overrides Sub OnInit(ByVal e As EventArgs) If Me.DisableAfterClick And Not Me.IsHiddenFieldRegistered Then MyBase.Page.RegisterHiddenField(Me.OnceClickBtnName, "") End If MyBase.OnInit(e) End Sub
Private Function IsHiddenFieldRegistered() As Boolean For Each ctl As Control In MyBase.Page.Controls If TypeOf ctl Is HtmlControls.HtmlInputHidden Then If ctl.ID = Me.OnceClickBtnName Then Return True End If End If Next Return False End Function
Protected Overridable Sub OnClick(ByVal e As EventArgs) RaiseEvent Click(Me, e) End Sub
Protected Overridable Sub OnCommand(ByVal e As System.Web.UI.WebControls.CommandEventArgs) RaiseEvent Command(Me, e) End Sub
Private Sub RaisePostBackEvent(ByVal eventArgument As String) Implements System.Web.UI.IPostBackEventHandler.RaisePostBackEvent If Me.CausesValidation Then MyBase.Page.Validate() End If Me.OnClick(New EventArgs) Me.OnCommand(New System.Web.UI.WebControls.CommandEventArgs(Me.CommandName, Me.CommandArgument)) End Sub
Private Function EscapedMessage(ByVal strMsg As String) As String Return Replace(ConfirmationMessage, "'", "\'") End Function
End Class
-- modified at 10:49 Tuesday 2nd May, 2006
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
|
 |
Hi, Have u ever tested with asp.net/c#. I have tried to use your dll but it does not work with c# application, whereas it works fine with vb application. Please solve this issue.
Compiler Error Message: CS0234: The type or namespace name 'ClickOnceButton' does not exist in the class or namespace 'ClickOnceButton.ClickOnceButton' (are you missing an assembly reference?)
-- modified at 1:55 Tuesday 2nd May, 2006
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi Anjum Rizwi,
Simply add namespace to the vb class, like following:
Namespace ClickOnceButton
<ToolboxData("<{0}:PromptClickOnceButton runat=""server"" />"), ToolboxBitmap(GetType(System.Web.UI.WebControls.Button)), DefaultEvent("Click")> _ Public Class PromptClickOnceButton Inherits System.Web.UI.WebControls.WebControl Implements IPostBackEventHandler
.....
End Class
End Namespace The namespace name have to be different with the class name. Complile it, and then you could use the new dll in your C# project. I have tested it in a C# web application. It works fine.
By the way, I added a new feature to this PromptClickOnce button. The idea is from Mika. All buttons become disabled on the web form when one button is clicked. Only one property's code (GetClickOnceJavascript) is changed.
<Browsable(False)> _ Friend ReadOnly Property GetClickOnceJavascript() As String
Get
Dim sb As New StringBuilder
sb.Append("for(var f=0; f < document.forms.length; f++)") sb.Append("{") sb.Append("var lForm = document.forms[f];") sb.Append("for(var e=0; e < lForm.elements.length; e++)") sb.Append("{") sb.Append("var lElement = lForm.elements[e];") sb.Append("if (lElement.type == 'button' || lElement.type == 'submit')") sb.Append("lElement.disabled = true;") sb.Append("}") sb.Append("}") sb.Append("document.getElementsByName('") sb.Append(Me.OnceClickBtnName) sb.Append("').item(0).setAttribute('name',") sb.Append("this.getAttribute('name'));")
If Not (DisabledText = String.Empty) Then
sb.Append("this.value = '") sb.Append(DisabledText) sb.Append("';")
End If
sb.Append("this.form.submit();")
Return sb.ToString()
End Get
End Property
Hope this can help you.
Xiang Qin
-- modified at 10:53 Tuesday 2nd May, 2006
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Thank You qherb for promt reply with solution I have tested it is OK. Now I m going to use in my application
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
This is great, I think Microsoft should have added this functionality to ASP.NET 2.0 as standard.
I would like to see something like this with Images, where you can set Image.Visible = True without refreshing, just like VB windows forms. Thank you
|
| Sign In·View Thread·PermaLink | 5.00/5 |
|
|
|
 |
|
|
 |
|
 |
one issue that can happen with the implementation of this control is that if you do a javascript document.form.submit(), it will not fire the OnSubmit javascript event on the page, which I need for another control i developed. I came up with a solution. The following subroutine was changed:
Friend ReadOnly Property GetOnceClickJavascript() As String Get Return "document.getElementsByName('" + Me.OnceClickBtnName + "').item(0).setAttribute('name'," + _ "this.getAttribute('name')); this.disabled = true; " + _ IIf(DisabledText = String.Empty, String.Empty, "this.value = '" + DisabledText + "';") + _ Me.Page.GetPostBackEventReference(Me) & ";" '"this.form.submit();" End Get End Property
notice the last part of the string now using GetPostBackEventReference. I just discovered this little function a few days ago. never even knew it existed, but it seems to work perfect. now i get a click once button that also fires the onsubmit event on the page.
|
| Sign In·View Thread·PermaLink | 1.00/5 |
|
|
|
 |
|
 |
Hey this thread is awesome! Thanks everybody for your input.
Here is my modified C# version - it's very simple and works pretty well for my purpose, but I'd like to extend it further.
- It works fine so that when you click a button: it will disable ALL buttons, links and hyperlinks on the form until it reloads. (to use this scenario, I send 'true' to the SetSafeButton() function.
The feature that is NOT working the way I'd like is that if you click the button and set the code to also disable things like textboxes, dropdown lists, and checkboxes(Sending 'false' to the SetSafeButton() function) - it will clear out their values. Does anybody have a quick fix for that one for the code below?
Thanks!!!
------------
private void Page_Load(object sender, System.EventArgs e) { if(!IsPostBack) setSafeAllControls(this.Page); }
void setSafeAllControls(Page thispage) { foreach (Control elem in thispage.Controls) { if (elem.GetType().ToString().Equals("System.Web.UI.HtmlControls.HtmlForm")) { foreach (Control child in elem.Controls) { if (child.GetType().ToString().Equals("System.Web.UI.WebControls.Button")) { SetSafeButton(this.Page, true, (Button)child); } } } } }
public static void SetSafeButton(Page thisPage, bool lockStaticControlsOnly, System.Web.UI.WebControls.Button button) { StringBuilder sb = new System.Text.StringBuilder(); if(button.CausesValidation) { sb.Append("if (typeof(Page_ClientValidate) == 'function') { "); sb.Append("if (Page_ClientValidate() == false) { return false; }} "); } sb.Append("this.disabled = true;"); foreach (Control elem in thisPage.Controls) if (elem.GetType().ToString().Equals("System.Web.UI.HtmlControls.HtmlForm")) { foreach (Control child in elem.Controls) { if(!lockStaticControlsOnly) { switch(child.GetType().ToString().Replace("System.Web.UI.WebControls.","")) { case "Button": case "LinkButton": case "HyperLink": case "TextBox": case "CheckBox": case "CheckBoxList": case "RadioButton": case "RadioButtonList": sb.Append(child.ClientID+".disabled = true;"); break; default: break; } } else { switch(child.GetType().ToString().Replace("System.Web.UI.WebControls.","")) { case "Button": case "LinkButton": case "HyperLink": sb.Append(child.ClientID+".disabled = true;"); break; default: break; } } } } sb.Append(thisPage.Page.GetPostBackEventReference(button)); sb.Append(";"); button.Attributes.Add("onclick", sb.ToString()); }
private void btnSubmit_Click(object sender, System.EventArgs e) { Thread.Sleep(2000); Label1.Text+=" OK"; }
private void btnCancel_Click(object sender, System.EventArgs e) { Thread.Sleep(2000); Label1.Text = ""; }
Trond
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
|
 |
ok so I plugged this in and realized it has bugs. If the page is already invalid from for example a requiredFieldValidator kicking in, and I click a button - the clicked button will just stay disabled - as Eric mentioned initially.
My goal for my approach is to have one function that I could invoke once per page (e.g. in page_load for a usercontrol for my projects navbar) that will scan the page automatically for buttons and attach the javascript to them... So if anyone has a suggestion on how to fix this, i'd be psyked!!!
Thanks again,
T
|
| Sign In·View Thread·PermaLink | 1.00/5 |
|
|
|
 |
|
 |
OK I got that bug fixed so now it seems pretty flawless - I'll post the code if anyone's interested. It is however limited to only work for buttons....
Trond
|
| Sign In·View Thread·PermaLink | 1.00/5 |
|
|
|
 |
|
 |
Hey Trondborg,
I am trying to use the DLL to implement it in my web solution which is written in C#. I am referencing the DLL, Added the modified button control to my Tool Box, added this control to the page with all required steps. When I run the page, I comeup with the following error (see below). It seems you were able to run this control in your c# code, what changes did you make? I dont understand the code which you posted. Please help!!
================================================================================================= Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0234: The type or namespace name 'ClickOnceButton' does not exist in the class or namespace 'ClickOnceButton.ClickOnceButton' (are you missing an assembly reference?)
Source Error:
Line 1607: Line 1608: private System.Web.UI.Control __BuildControlClickOnceButton1() { Line 1609: ClickOnceButton.ClickOnceButton __ctrl; Line 1610: Line 1611: #line 240 "http://localhost/GiantBed/ControlModules/RegistrationForm.ascx"
Source File: c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\giantbed\48896e80\3e53f560\nhb1rk62.0.cs Line: 1609
|
| Sign In·View Thread·PermaLink | 2.50/5 |
|
|
|
 |