I have checkbox in a gridview, when you click on the checkbox i need to show confirm message box.
i want to change the confirm message box button text from 'OK'/'cancel' to 'Yes'/No
For this i am using JQuery plugin http://www.invetek.nl/samples/confirmon/index.php
My gridView below
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"
style="text-align:center" CellPadding="3" BackColor="White" BorderColor="#999999" BorderStyle="Solid"
BorderWidth="1px" ForeColor="Black" Font-Bold="false" GridLines="Vertical" RowStyle-CssClass="GridRow"
OnRowCommand="GridView1_RowCommand"><%--OnRowDataBound="GridView1_RowDataBound"--%>
<AlternatingRowStyle BackColor="#F8F8F8" />
<Columns>
<asp:TemplateField Visible="false">
<ItemTemplate>
<asp:Label ID="lbl_CarBrandID" runat="server" Text='<%# Eval("CarBrandID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="10%" HeaderText="Brand Name" HeaderStyle-CssClass="header-center">
<ItemTemplate>
<asp:Label ID="lbl_CarBrandName" runat="server" Text='<%# Eval("CarBrandName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="5%" HeaderText="Active" HeaderStyle-CssClass="header-center">
<ItemTemplate>
<asp:checkbox ID="lbl_Active" runat="server" AutoPostBack="true" OnCheckedChanged="chkIsActive_CheckedChanged" Checked='<%# Eval("IsEnabled") %>'></asp:checkbox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="5%" HeaderText="Models" HeaderStyle-CssClass="header-center">
<ItemTemplate>
<asp:Button ID="img_Save" runat="server" OnClientClick="ShowModel()" CommandArgument='<%# Eval("CarBrandID") %>' CommandName="ShowCarModels" Width="100%" Text="Display Models" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
my JQuery for checkbox change
<script>
$(document).ready(function () {
$('input[id*=lbl_Active]').confirmOn('change', function (e, confirmed)
{
if (confirmed)
{
alert("1")
$(this).remove();
}
else
{ // Clicked no
alert("2");
}
});
});
</script>
I am getting the confirm box only once (first time) after page load, if i check uncheck again then the message box does not appear. i want for every click of checkbox i need the message box to show. please help me out.
Related
I have following grid
<asp:GridView ID="grdBOQ" width="100%" ShowHeaderWhenEmpty="true" AutoGenerateColumns="false" runat="server" CssClass="gvBOQdatatable">
<Columns>
<asp:TemplateField HeaderText="Sl No:">
<ItemTemplate>
<%#(grdBOQ.PageSize * grdBOQ.PageIndex) + grdBOQ.Rows.Count + 1%>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" Width="40px" Wrap="False" />
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Category Name">
<ItemTemplate>
<asp:Label runat="server" Text='<%# Bind("Category_Name") %>' ID="lblCategoryName" ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Category Description">
<ItemTemplate>
<asp:Label runat="server" Text='<%# Bind("Description") %>' ID="lblCategoryDescription" ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Quantity">
<ItemTemplate>
<asp:TextBox ID="txtQuantity" class="form-control" runat="server" Text="0" MaxLength="8"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Unit">
<ItemTemplate>
<asp:Label runat="server" Text='<%# Bind("UOM_Name") %>' ID="lblUnit" ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Unit Rate">
<ItemTemplate>
<asp:Label runat="server" Text='<%# Bind("SellingPrice_Per_UOM") %>' ID="lblUnitRate" ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Total">
<ItemTemplate>
<asp:Label runat="server" Text='0.00' ID="lblTotalPrice" ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<div style="width: 99%; text-align: center">
<asp:Label ID="lblEmpty" runat="server" Text="Sorry!!! No Record Found.."></asp:Label>
</div>
</EmptyDataTemplate>
</asp:GridView>
I have given following code in script tag using jquery to find asp textbox value but not working. I tried 2 different way but not getting.
First way
$("#txtQuantity").on('click', function () {
alert('testing');
});
Second Way
var recipient = $("#txtQuantity")
$("#<%=recipient.ClientID%>").on('change', function () {
alert('testing');
});
Nothing works what is the way to get. I tried the above code inside document.ready and inside aspcontent tag.As it is in grid I have now around 5 textboxes and it varies based on the values from database.
Finally I have some thing like this but no idea this is a good solution.Please advice
$("#<%=grdBOQ.ClientID %>").on('change', function () {
var GridView1 = document.getElementById('<%= grdBOQ.ClientID %>');
for (var rowId = 1; rowId < GridView1.rows.length; rowId++) {
var textValue = GridView1.rows[rowId].cells[3].children[0];
if (textValue.value != '0')
alert(textValue.value);
}
});
What I am trying to do is click a link and have my webpage open as a popup not go to the webpage.
<asp:GridView ID="caseloads" runat="server" AutoGenerateColumns="false" GridLines="None"
Font-Size="12.5px" BackColor="#FFFFFF" CssClass="mGrid" OnSorting="caseloads_Sorting"
AllowSorting="true">
<Columns>
<asp:TemplateField HeaderText="View">
<ItemTemplate>
<a id="popup" href='erAlerts.aspx?id=<%#Eval("ClientKey") %>'>View</a>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Client ID" SortExpression="ClientKey">
<ItemTemplate>
<asp:Label ID="clientKey" runat="server" Text='<%#Eval("ClientKey")%>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Full Name" SortExpression="ConsumerName">
<ItemTemplate>
<asp:Label ID="clientKey" runat="server" Text='<%#Eval("ConsumerName")%>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Program" SortExpression="pgmName">
<ItemTemplate>
<asp:Label ID="clientKey" runat="server" Text='<%#Eval("pgmName")%>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="House" SortExpression="phoneH">
<ItemTemplate>
<asp:Label ID="clientKey" runat="server" Text='<%#Eval("phoneH")%>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Cell" SortExpression="phoneC">
<ItemTemplate>
<asp:Label ID="clientKey" runat="server" Text='<%#Eval("phoneC")%>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
So when I click "View" I want to be able to go to display my erAlerts.aspx.
I have tried a some but they either don't seem to work or they will open then redirect me to the page anyways after close.
I had a working one before but forgot to make a backup of it and for some reason I am lost. I can't for the life of me figure out how I did it.
Here is my code using jQuery Datatable
<script type="text/javascript">
$(function () {
$("#<%=grdEmployee.ClientID%>").dataTable();
})
</script>
Here is My GridView Code
<asp:GridView ID="grdEmployee" runat="server" PageSize="5" AutoGenerateColumns="false" OnPageIndexChanging="grdEmployee_PageIndexChanging" AllowPaging="true" AllowSorting="true">
<Columns>
<asp:TemplateField HeaderText="Emp ID" SortExpression="Emp ID">
<ItemTemplate>
<asp:Label ID="lblEmpID" runat="server" Text='<%#Eval("Empid") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Emp Name" SortExpression="Emp Name">
<ItemTemplate>
<asp:Label ID="lblEmpName" runat="server" Text='<%#Eval("EmpName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Emp Salary" SortExpression="Emp Salary">
<ItemTemplate>
<asp:Label ID="lblEmpSalary" runat="server" Text='<%#Eval("Salary") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:LinkButton ID="lnkEdit" runat="server" Text="Edit" CommandArgument='<%#Eval("Empid") %>' CommandName="eEdit"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="lnkDelete" runat="server" Text="Delete" CommandArgument='<%#Eval("Empid") %>' CommandName="eDelete"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
When I set GridView page size property to 5, it will give me a data table warning.
My database has 9 records and when I change the pagesize value from 5 to 10, it will not return any warning.
I have a formview on my web page and I want to change formview mode. But I want to change this with javascript.
Is this possible?
i have a repeater which has buttons. And i have a button outside of repeater. when i click the button where is outside, it shows formview in popup. this formview has to be insert mode. And when i click the button where is on repeater, it shows formview in popup. this formview has to be edit mode. But i cant do this c#. may be if i do this with javascript, it will works
<asp:ToolkitScriptManager ID="toolkitmanager1" runat="server"></asp:ToolkitScriptManager>
<asp:LinkButton runat="server" ID="lnkFake" />
<asp:ImageButton ID="img1" runat="server" PostBackUrl="javascript:$find('popUpBehavior').show();"/>
<asp:ModalPopupExtender BackgroundCssClass="modalBackground" ID="popUpCompanyEmployee"
runat="server" PopupControlID="panel1"
TargetControlID="lnkFake" BehaviorID="popUpBehavior" CancelControlID="btnKapat">
</asp:ModalPopupExtender>
<asp:Panel ID="panel1" runat="server" CssClass="modalPopup">
<asp:UpdatePanel ID="updatepanel1" runat="server">
<ContentTemplate>
<asp:FormView ID="fv1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="ID" DefaultMode="Insert">
<InsertItemTemplate>
<asp:Label ID="lblProductName" runat="server" Text="ProductName"></asp:Label>
<asp:TextBox ID="txtProductName" runat="server" Text='<%# Eval("ProductName") %>'></asp:TextBox>
<asp:Label ID="lblQuantity" runat="server" Text="Quantity"></asp:Label>
<asp:TextBox ID="txtQuantity" runat="server" Text='<%# Eval("Quantity") %>'></asp:TextBox>
<asp:Label ID="lblUnitPrice" runat="server" Text="UnitPrice"></asp:Label>
<asp:TextBox ID="txtUnitPrice" runat="server" Text='<%# Eval("UnitPrice") %>'></asp:TextBox>
</InsertItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblProductName" runat="server" Text="ProductName"></asp:Label>
<asp:TextBox ID="txtProductName" runat="server" Text='<%# Eval("ProductName") %>'></asp:TextBox>
<asp:Label ID="lblQuantity" runat="server" Text="Quantity"></asp:Label>
<asp:TextBox ID="txtQuantity" runat="server" Text='<%# Eval("Quantity") %>'></asp:TextBox>
<asp:Label ID="lblUnitPrice" runat="server" Text="UnitPrice"></asp:Label>
<asp:TextBox ID="txtUnitPrice" runat="server" Text='<%# Eval("UnitPrice") %>'></asp:TextBox>
</EditItemTemplate>
</asp:FormView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnKapat"/>
</Triggers>
</asp:UpdatePanel>
<asp:Button ID="btnkapat" runat="server" Text="kapat"/>
</asp:Panel>
<asp:Repeater ID="rpr1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<asp:Label ID="lblID" runat="server" Text='<%#Eval("ID") %>'></asp:Label>
<asp:Label ID="lblProductName" runat="server" Text='<%#Eval("ProductName") %>'></asp:Label>
<asp:Label ID="lblQuantity" runat="server" Text='<%#Eval("Quantity") %>'></asp:Label>
<asp:Label ID="lblUnitPrice" runat="server" Text='<%#Eval("UnitPrice") %>'></asp:Label>
<asp:ImageButton ID="imgPopup" runat="server" PostBackUrl="javascript:$find('popUpCBehavior').show();" />
</ItemTemplate>
</asp:Repeater>
<asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString='<%$ ConnectionStrings:NET2ConnectionString %>' SelectCommand="SELECT * FROM [ProductsRA]"></asp:SqlDataSource>
Basically, changing the mode of a FormView reflects what controls (html) are rendered to the page.
So it could not happen purely on client-side. You could use an update panel , so only an asyn post backis done and only the form view html is refreshed.
Have a look for reference Formview
Documentation for reference here
Hope it clears your doubt a bit
In my asp.net web page i have a grid & button.
Code :
<asp:GridView ID="gdvw" runat="server" AutoGenerateColumns="false" Width="100%" EmptyDataText="No record(s) found">
<Columns>
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="status">
<ItemTemplate>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="view">
<ItemTemplate>
<div id='divView'>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<input type="submit" id="btnView" runat="server" value="View">
the inner text of div View div(in 'view' column), that contains only one of the following two texts. 'true' and 'false'. if the text is 'true' then the submit button should be visible. else if the text is 'false' then the submit button should be hidden.