• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 593
  • Last Modified:

Can I call two functions from an onclick event?

                                    <asp:Button ID="btnStudentInfoUpdate" runat="server"
                                       onclick = "btnStudentInfoUpdate_Click" Text="Update" 
                                        ToolTip="Only allows updates to the Music Teacher and the Comments fields" 
                                        Width="94px" />

Open in new window


I'm trying to do somehting like this:
onclick = "btnStudentInfoUpdate_Click;_highlightTextbox()" Text="Update"

The btnStudentInfoUpdate_Click is a function in my code behind and the _highlightTextBox() is a javascript function.

When I run this I get this error:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1026: ) expected

Source Error:

 

Line 576:                                <td align="right" style="background-color: #BED2EA;" class="style81">
Line 577:                                    <br />
Line 578:                                    <asp:Button ID="btnStudentInfoUpdate" runat="server"
Line 579:                                       onclick = "btnStudentInfoUpdate_Click;_HighlightTextBox()" Text="Update"
Line 580:                                        ToolTip="Only allows updates to the Music Teacher and the Comments fields"
 
0
JosephNBurton
Asked:
JosephNBurton
1 Solution
 
jjardineCommented:
I don't think this is going to work.  If you are trying to call the client side code after the server call, in the server call, add a Registerclientscript  call to run the script when the page re-loads.
0
 
HonorGodSoftware EngineerCommented:
Can you call the _HighlightTextBox() routine, and then the submit?
0
 
Abirami RajendranCommented:
Call the javascript function _HighlightTextBox() using OnClientClick attribute of the button.
 
<asp:Button ID="btnStudentInfoUpdate" runat="server"
onclick = "btnStudentInfoUpdate_Click" onclientclick = "_HighlightTextBox" Text="Update" 
ToolTip="Only allows updates to the Music Teacher and the Comments fields" 
Width="94px" />

Open in new window

0
 
JosephNBurtonAuthor Commented:
@HonorGod

That didn't work.

@sansoftura:
I tried that at first and it works, but when it goes through the Page_Load function again it unhighlights the textbox.
0
 
JosephNBurtonAuthor Commented:
I have reacted too soon. I need to object to my own cancellation. I need to reward the points to sansoftura
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now