Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to wire to buttons together to display the same message

Status
Not open for further replies.

taree

Technical User
May 31, 2008
316
US

I have two button in my page and I am using the below code and I am just wondering if there is a way to wire the two buttons together and when I click one of them I want both to be disabled and show "processing please wait..." message. thank you for the help

Code:
 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        btnSelect.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(btnSelect, "") _
                          & ";this.value='Processing Please wait...';this.disabled = true;this.style.backgroundColor = '';")
        Button2.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(Button2, "") _
                         & ";this.value='Processing Please wait...';this.disabled = true;this.style.backgroundColor = '';")
        lblError.Visible = False
        If Not IsPostBack Then
            LetBind()
            lblTody.Text = Servertime.CurrentTime
        End If
        BindData()
    End Sub



 Protected Sub btnSelect_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSelect.Click, Button2.Click

        System.Threading.Thread.Sleep(1000)
        ClientScript.RegisterClientScriptBlock(Me.GetType, _
            "reset", "document.getElementById('" & btnSelect.ClientID & "').disabled=false;", True)
        ClientScript.RegisterClientScriptBlock(Me.GetType, _
            "reset", "document.getElementById('" & Button2.ClientID & "').disabled=false;", True)
 
1st problem. you are writing the client script in the button click event. the user will never get a disabled button or wait message.

instead you need to do this on the client using js. i would recommend jquery/prototype/dojo to write the js code.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Hi Jason,

Actuall it is working fine the only problem is I want both to display the wait message at the same time. otherwis, when i click one by one it displays the message....
 
your right, overlooked the page load.

I still recommend a js library rather than litter the server code with client code. the code behind should not care what the markup does, it should only push/pull data. what the makup does while the data is transferred is irrelevant.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top