开发者

Where to write JavaScript to Validate updating record in GridView?

开发者 https://www.devze.com 2023-04-10 14:47 出处:网络
I am using *GridView1_RowCommand* event method to Insert, Update record. I want to use JavaScript clientside validation to validate record in update mode. Where can I write JavaScript to make it fire

I am using *GridView1_RowCommand* event method to Insert, Update record. I want to use JavaScript clientside validation to validate record in update mode. Where can I write JavaScript to make it fire when clicked on the update butt开发者_StackOverflowon?


If you are familiar (know-how of) with the JavaScript language, you can write JavaScript in .aspx (markup) or external JavaScript file particularly. If not than use ASP.NET validation controls. Note that to validate user input you must have to convert GridView fields to "TemplateFields".


I would use a TemplateField, and put the update button in the EditItemTemplate. Assign the correct CommandName to link up to the RowCommand event, and use OnClientClick to trigger validation.

<EditItemTemplate>
    <asp:Button ID="btnUpdate" runat="server" CommandName="Update" OnClientClick="validateData(this);" />
</EditItemTemplate>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号