GornHorse Posted February 7, 2004 Posted February 7, 2004 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 Quote
Tryster Posted February 9, 2004 Posted February 9, 2004 You could amend your DumpData JScript function to take the button as a parameter. The you could change this line: cbDBText.Attributes("onchange") = "DumpData();" To this: cbDBText.Attributes("onchange") = String.Format("DumpData({0});", cbDBButton.ClientId) That should work... Quote
GornHorse Posted February 9, 2004 Author Posted February 9, 2004 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 Quote
GornHorse Posted February 9, 2004 Author Posted February 9, 2004 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 Quote
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.