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

How can i attach java script function to Insert and update buttons for client side validation

3 Answers 116 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Krishna
Top achievements
Rank 1
Krishna asked on 14 Jul 2008, 09:28 PM
Hi..
If you have any code snippet to attach the Javascript funtion to Insert and Update record buttons of command items Please send it to me.

Thanks
-krishna

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 15 Jul 2008, 05:11 AM
Hi Krishna,

You can use the ItemCreated event of the grid to locate the Insert/Update  button and use its OnClientClick property to launch custom javascript.

CS:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
         if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted) 
          { 
            GridEditFormInsertItem item = e.Item as GridEditFormInsertItem; 
            LinkButton insertButton = item.FindControl("PerformInsertButton") as LinkButton; 
            insertButton.OnClientClick = "Show();"
 
         } 
 
    } 

JS:
<script type="text/javascript"  language="javascript" > 
         function Show() 
         { 
          alert('Hi') 
         } 
           
        </script> 


Thanks
Shinu.
0
Krishna
Top achievements
Rank 1
answered on 15 Jul 2008, 08:17 PM
Hi Shinu..
where to specify the name "PerformInsertButton" in ASPX page..
i have mentioned as below

<

EditColumn UniqueName="InsertButton"

but it doestnt seems to be working ..
can u please help me out again

Thanks,
-Krishna

0
Krishna
Top achievements
Rank 1
answered on 15 Jul 2008, 08:38 PM
I found out  the problem
it should be as below then it works fine

else if (e.Item is GridEditableItem)

{

LinkButton insertButton = (LinkButton)e.Item.FindControl("PerformInsertButton");

Thanks for the help

Tags
Grid
Asked by
Krishna
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Krishna
Top achievements
Rank 1
Share this question
or