This is a migrated thread and some comments may be shown as answers.

[Solved] Unable to find clientid of a button

1 Answer 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 16 Nov 2009, 04:07 PM
Hi,

I had a javascript prompt box which is being displayed upon some business validations and when the user clicks ok, I was trying to fire click event of a button to perform insert operation but I am unable to find the ID of the button, I am registering the javascript in code behind using scriptmanager.registerstartupscript, my web page has a master page, radgrid, update panel, radloadingpanel.
below is the code where i am trying to pull the ID of the button.
Dim js As String  
        js = _ 
                       "       var promptpromptComments=prompt(Validation failed, still want to proceed','Comments...');" & _  
                       "       if(promptComments!=null && promptComments!='')" & _  
                       "       {" & _  
                       "        document.getElementById('<% InsertRecord.ClientID %>').click;"  & _  
                       "        document.getElementById('InsertCmtsHdnFld').value=promptComments;" & _  
                       "       } " & _  
                       "       else" & _  
                       "       {" & _  
                       "       alert('insert has been terminated');" & _  
                       "       }"  
 
        ScriptManager.RegisterStartupScript(Me, GetType(Page), "PromptScript", js, True) 
Also I am unable to find the hidden field id as well

I am doing this so as to perform an insert operation based on the response from user. Hence trying to fire a click event and perform insert operation in it.

I am registering the javascript in insert command event. I must be missing something eay here but unable to find it, Anyhelp would be greatly appreciated.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 17 Nov 2009, 07:52 AM
Hi Kevin,

If you want to perform insert based on customer response, then one suggestion would be using the firecommand method instead of getting the ClientID of insert button and invoking the click method.

Also I am not sure about where you placed the HiddenField control. Could you provide some more information about the scenario?

Feel free to share the comments,
Shinu.
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or