Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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...

Posted

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

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...