HtmlInputButton - force the .click() event

GornHorse

Centurion
Joined
May 27, 2003
Messages
105
Location
Australia
G'Day,

I have a combobox that has the following child controls - cbDBButton (HtmlInputButton), cbDBHidden (HtmlInputText), and cbDBText (TextBox). I have declared each of these child controls on the server-side.

Ie, cbDBButton is declared as:
Public WithEvents cbDBButton as new System.Web.UI.HtmlControls.HtmlInputButton

Then, in the page_load, i declare the following:
cbDBButton = cbDB.ProcessButton
cbDBButton.ID = "cbDBButton"
cbDBButton.Attributes("runat") = "server"

cbDBHidden = cbDB.Hidden
cbDBText = cbDB.TextBox
cbDBText.Attributes("onchange") = "DumpData();"
'(NB that cbDB is the combobox control)

Ok, now the DumpData() function gets called fine (javascript). However, what i need to do from here is force the cbDBButton's serverclick event, so that it can call the sub which handles the event.

I have tried the following:
Document.Form1.cbDBButton.click();

But, i get the following error:
'Document.Form1.cbDBButton' is null or not an object.

How can i force the cbDBButton.click() event from the client without getting this error?

A quick reply would be excellent.


Ta,
Michelle
 
You could amend your DumpData JScript function to take the button as a parameter. The you could change this line:
Visual Basic:
cbDBText.Attributes("onchange") = "DumpData();"
To this:
Visual Basic:
cbDBText.Attributes("onchange") = String.Format("DumpData({0});", cbDBButton.ClientId)

That should work...
 
G'Day,

Thanks for that. Just one quick question (to prove my uselessness), how do i then use the paramter in javascript?

How do i pass this parameter and fire the .click() event?

Thanks very much,
Michelle
 
Ok,
Perhaps you can scratch that last query... maybe.

I have done this...

Function DumpData(btn){
btn.click();
}

Except, now i get the error:
cbDBButton is undefined.

Please help??!!

Thanks again,
Michelle
 
Back
Top