TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mata
NA
46
34.5k
Gridview confirm checkbox javascript problem
Dec 22 2011 4:07 PM
I want to confirm with javascript checked true before triggering checkedChanged event on server side
this is filling checkbox in edit mode
private void potvrdaGreskaReprint(GridViewRowEventArgs e)
{
CheckBox ch = (CheckBox)e.Row.FindControl("cbGreska");
ch.Attributes.Add("onclick", "confirmation(" + ch.UniqueID + ")");
}
next is javascript function:
<script language="javascript" type="text/javascript">
function confirmation(checkbox) {
if (checkbox.checked == true) {
var answer = confirm('Really confirm');
if (answer) {
__doPostBack(checkbox, '');
return true;
}
else {
checkbox.checked = false; return false;
}
}
}
</script>
defining checkbox in gridview:
<asp:TemplateField HeaderText="Greška" ItemStyle-HorizontalAlign="Center" SortExpression="greska">
<EditItemTemplate>
<asp:CheckBox ID="cbGreska" runat="server" Checked='<%# Bind("greska") %>' OnCheckedChanged="cbGreska_OnCheckedChanged" />
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lbGreska" runat="server" Text='<%# Eval("greska") %>' Visible="false"></asp:Label>
<asp:Image ID="imgGreska" runat="server" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:TemplateField>
Finally checked changed event on server side
protected void cbGreska_OnCheckedChanged(object sender, EventArgs e)
{
CheckBox ch = (CheckBox)sender;
if (ch.Checked)
{......
So basicly I want to trigger checked Changed event with javascript
On debugging I get "Error: Object doesn't support property or method 'replace' "
at __doPostBack(checkbox, ''); line in javascript function
Reply
Answers (
1
)
WebForms
What is ASP.NET Custom controls?