My code:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:GridView runat="server" ID="MyGridView" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Col1" HeaderText="Column 1" />
<asp:BoundField DataField="Col2" HeaderText="Date 1" />
<asp:BoundField DataField="Col3" HeaderText="Date 2" />
<asp:TemplateField HeaderText="Date 2" >
<EditItemTemplate>
<asp:TextBox ID="txtDate" CssClass="datepickerCompleted"
runat="server" Text="2011/1/1" ></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Col4" HeaderText="Date 3" />
<asp:TemplateField HeaderText="Date 3"></asp:TemplateField>
</Columns>
</asp:GridView>
<script type="text/javascript" language="javascript" src="<%= VirtualPathUtility.ToAbsolute("~/Script/jquery-1.4.1-vsdoc.js")%>"></script>
<script type="text/javascript">
$(function () {
$(".datepickerCompleted").datepicker();
});
</script>
</asp:Content>
Followed example from here:
enter link description here
When I look at the source, i do not see any value populate in txtDate text box, which i suspect is then not firing the jquery method..
how do i debug?
Your code looks good, but the datepicker is part of jQuery UI which is a separate download/script--it's not included in the jquery-1.4.1 file, and it looks like that's the only script you have referenced.
EDIT: Here's an example that works for me:
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script src="Scripts/jquery-ui-1.8.12.custom.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$(".datepickerCompleted").datepicker();
});
</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:GridView runat="server" ID="MyGridView" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="Date 2">
<ItemTemplate>
<asp:TextBox ID="txtDate" CssClass="datepickerCompleted" runat="server" Text="2011/1/1" ></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</asp:Content>
You can download a copy of jQuery UI here, and here's some more information on the datapicker.
Based on the active/voted Answer, I think one more statement shall be added for better visibility of the datepicker. Otherwise it would be blurred/dimmed by the background. The proposed statement is put at 2nd line (assuming jquery-ui-1.8.14.custom.css file is downloaded & put in Css folder):
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<link type="text/css" href="Css/jquery-ui-1.8.14.custom.css" rel="Stylesheet" />
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script src="Scripts/jquery-ui-1.8.12.custom.min.js" type="text/javascript"></script>
...
Related
Is it possible to use UpdatePanel control with navigating through the left panel (menu)?
In Main.master there are left menu
<dx:ASPxNavBar ID="ASPxNavBar1" runat="server" AutoCollapse="True" EnableAnimation="True" Width="100%">
<dx:NavBarGroup Text="Group">
<Items>
<dx:NavBarItem NavigateUrl="Content/Content1.aspx" Text="Content1"></dx:NavBarItem>
<dx:NavBarItem NavigateUrl="Content/Content2.aspx" Text="Data Subject"></dx:NavBarItem>
</Items>
</dx:NavBarGroup>
</dx:ASPxNavBar>
and I'm trying to use refresh only content using UpdatePanel control
<div class="contentPane">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" updatemode="conditional">
<ContentTemplate>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
but it doesn't work; header and menu still reloading when navigating through the menu.
Content1.aspx and Content2.aspx files have just an usual content inside of <asp:content> tag
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" KeyFieldName="PK" Width="750px">
<Columns>
<dx:GridViewCommandColumn ShowNewButtonInHeader="True" VisibleIndex="0" ShowDeleteButton="True" ShowEditButton="True">
</dx:GridViewCommandColumn>
<dx:GridViewDataTextColumn FieldName="PK" ReadOnly="True" Visible="false" VisibleIndex="1">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Name" VisibleIndex="2">
</dx:GridViewDataTextColumn>
</Columns>
</dx:ASPxGridView>
</asp:Content>
I wonder why you are using an UpdatePanel is that a requeriment?
I would use an ASPxCallbackPanel which is a great replacement for the UpdatePanel and you can use it since you are using DevExpress controls
<script type="text/javascript">
var postponedCallbackRequired = false;
function OnListBoxIndexChanged(s, e) {
if(CallbackPanel.InCallback())
postponedCallbackRequired = true;
else
CallbackPanel.PerformCallback();
}
function OnEndCallback(s, e) {
if(postponedCallbackRequired) {
CallbackPanel.PerformCallback();
postponedCallbackRequired = false;
}
}
</script>
<dx:ASPxListBox runat="server" Height="221px" Width="100%" TextField="Name" DataSourceID="EmployeesDataSource1"
ValueField="EmployeeID" ID="ASPxListBox1" ClientInstanceName="ListBox" BackColor="Transparent">
<Border BorderWidth="0px"></Border>
<ItemStyle>
<Border BorderWidth="0px"></Border>
</ItemStyle>
<ClientSideEvents SelectedIndexChanged="OnListBoxIndexChanged" />
</dx:ASPxListBox>
<dx:ASPxCallbackPanel runat="server" ID="ASPxCallbackPanel1" Height="250px" ClientInstanceName="CallbackPanel" RenderMode="Table">
<ClientSideEvents EndCallback="OnEndCallback"></ClientSideEvents>
<PanelCollection>
<dx:PanelContent ID="PanelContent3" runat="server">
</dx:PanelContent>
</PanelCollection>
</dx:ASPxCallbackPanel>
You can see a complete sample code here
This is my first time using asp.net so pleaseaccept my apologies if this is a dumb question.
I am trying to make a web application that will work on our work sharepoint. the idea is a team of people can select when they are available to call or not and if they are the contact point that day so that people on different floors can see their availability without a line of sight.
i would normally make a basic php script but sharepoint doesnt like php and we cannot reference to external resources on our network.
The issue i have is the table that should be pulling data from the xml is just a blank page... originally it gave an error saying it couldnt find that data field and i realised i needed to use xpath to be more specific... it now doesnt give any error, like its finding the field but doesnt draw it. the code is below:
XML database:
<?xml version="1.0" encoding="utf-8" ?>
<CRM>
<agent>
<id>user1</id>
<name>name</name>
<turret>extension</turret>
<email>email</email>
<status>XXXXX</status>
<contact>N/A</contact>
</agent>
<agent>
<id>user2</id>
<name>Name 2</name>
<turret>extension</turret>
<email>email</email>
<status>XXXXX</status>
<contact>N/A</contact>
</agent>
<agent>
<id>user3</id>
<name>Name 3</name>
<turret>Extension Number</turret>
<email>email address</email>
<status>XXXXX</status>
<contact>N/A</contact>
</agent>
</CRM>
and the datagrid that should be pulling that data is here:
<%# Page Language="vb" AutoEventWireup="false" CodeBehind="CSTvisibility.aspx.vb" Inherits="CRM_availabilty.CSTvisibility" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:XmlDataSource ID="data" runat="server" DataFile="~/crmdata.xml" XPath="/agent"></asp:XmlDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BorderStyle="Ridge" DataSourceID="data">
<Columns>
<asp:BoundField DataField="name" HeaderText="CRM Agent" />
<asp:BoundField DataField="turret" HeaderText="Turret" />
<asp:BoundField DataField="email" HeaderText="Email" />
<asp:BoundField DataField="status" HeaderText="Available" />
<asp:BoundField DataField="contact" HeaderText="Contact Point" />
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
Switch to TemplateField instead of BoundField. Then you have access to the XPath.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" DataSourceID="data">
<Columns>
<asp:TemplateField HeaderText="CRM Agent">
<ItemTemplate>
<%# XPath("name") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Turret">
<ItemTemplate>
<%# XPath("turret") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Email">
<ItemTemplate>
<%# XPath("email") %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
The XPath in the XmlDataSource must be XPath="CRM/agent"
I have the code below.onClientClick event of the linkbutton showVlaues javascript function is executed. I tried to trace the code in the debug mode and when I click on the link button, the debuuger control is tranferred to the showvalues function and then it goes to the code behind and goes to page load event of the application and then it goes again to the showvalues function, I am not sure why it does that, but in debug mode, I can see that it goes to both the $get lines and when I tried to see the value of dataitems, it dataitems is not defined in current context and it changes the value of showValues. Is their any way I can avoid it that control does not go to showvalues function again. I want it to be executed only once when I click on the link button.
any help will be appreciated.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function showValues(IDValue, timeValue, minValue){
var dataItems = $get('<%= PanelBar1.Items[0].Items[0].FindControl ("Grid_IDPicker").ClientID %>')
var lbl_ID = $get('<%= PanelBar1.Items[0].Items[0].FindControl("lbl_ID").ClientID %>');
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
EmptyDataText="There are no data records to display.">
<Columns>
<asp:BoundField DataField="id" HeaderText="id" SortExpression="id" />
<asp:BoundField DataField="time" HeaderText="time" SortExpression="time" />
<asp:BoundField DataField="min" HeaderText="min" SortExpression="min" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkClick" OnClientClick='<%#String.Format("return showValues({0},'{1}','{2}')", Eval("id"),Eval("time"),Eval("min")) %>' runat="server"> <%# Eval("id") %></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TestDBConnectionString1 %>"
ProviderName="<%$ ConnectionStrings:TestDBConnectionString1.ProviderName %>"
SelectCommand="SELECT [id], [time], [min] FROM [name]"></asp:SqlDataSource>
</form>
</body>
</html>
Hi all i would like to work out this functionality for grdiveiw instead of table can any one guide me please.
http://fixedheadertable.com/
I tried this by registering the required scripts but didn't work for me so can any one help me
<asp:GridView ID="grdEarnings" runat="server" CssClass="myTable01" AutoGenerateColumns="False"
AlternatingRowStyle-BackColor="#DEE6F7" ShowHeader="true" Font-Size="11pt">
<Columns>
<asp:TemplateField ItemStyle-Width="150px" ItemStyle-HorizontalAlign="Center" HeaderText="ID">
<EditItemTemplate>
<asp:Label ID="lbl" runat="server" Text="<%#ID %>"></asp:Label>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="150px" ItemStyle-HorizontalAlign="Center" HeaderText="Name">
<ItemTemplate>
<asp:Label ID="lblRegular" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="150px" HeaderText="Price">
<ItemTemplate>
<asp:Label ID="lblPrice" runat="server" Text='<%# Eval("Price") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="150px" HeaderText="Description">
<ItemTemplate>
<asp:Label ID="lblDescription" runat="server" Text='<%# Eval("Description") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
The other one i tried works fine for me but as i am using tool tips in my application i included some scripts related to that when i include that i am unable to view the scroll bar for grid view
Untitled Page
<script src="Scripts/ScrollableGridPlugin.js" type="text/javascript"></script>
<script type="text/javascript"> $(document).ready(function () {
$('#<%=grdEarnings.ClientID %>').Scrollable({
ScrollHeight: 300
});
});
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
if i commented the scripts that were after the Jquery function this works well enough for me. But while running along with those scripts i am unable to view the scroll bar for gridview
You need to first include jQuery and then your jQuery plugin (ScrollableGridPlugin). Moreover I don't understand why you have multiple jQuery includes with different versions (1.4.2, 1.4.4, 1.3.2)?
Whether the jQuery ScrollableGridPlugin works with an ASP GridView rather than with a normal table depends on the HTML which is generated by the GridView.
(Moreover, shouldn't the call be $('selector').fixedHeaderTable({ footer: false, cloneHeadToFoot: true, fixedColumn: false }); according to the docs you provided?)
For the FixedHeaderTable plugin usage you need to add a thead element to grdidview and move the very first gridview's row into it:
$(function () {
var gridView = $("#<%= grdEarnings.ClientID %>");
gridView.prepend( $("<thead></thead>").append( gridView.find("tr:first") ) );
gridView.fixedHeaderTable({ height: '300' });
});
I am brand new to asp and downloaded some example code of a shopping cart. When I created a new project in Visual Studio, added all the files in and tried to compile I got the following error.
Error 1 The name 'gvShoppingCart' does not exist in the current context c:\users\slaphappysmoker\documents\visual studio 2010\Projects\Shopcart\Shopcart\ViewCart.aspx.cs 21 3 Shopcart
However I can see where gvShoppingCart gets defined in the ViewCart.aspx file.
<%# Page Language="C#" AutoEventWireup="true" CodeFile="ViewCart.aspx.cs" Inherits="ViewCart" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Shopping Cart</title>
<link href="Styles/StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div class="container">
<h1>Shopping Cart</h1>
< Back to Products
<br /><br />
<asp:GridView runat="server" ID="gvShoppingCart" AutoGenerateColumns="false" EmptyDataText="There is nothing in your shopping cart." GridLines="None" Width="100%" CellPadding="5" ShowFooter="true" DataKeyNames="ProductId" OnRowDataBound="gvShoppingCart_RowDataBound" OnRowCommand="gvShoppingCart_RowCommand">
<HeaderStyle HorizontalAlign="Left" BackColor="#3D7169" ForeColor="#FFFFFF" />
<FooterStyle HorizontalAlign="Right" BackColor="#6C6B66" ForeColor="#FFFFFF" />
<AlternatingRowStyle BackColor="#F8F8F8" />
<Columns>
<asp:BoundField DataField="Description" HeaderText="Description" />
<asp:TemplateField HeaderText="Quantity">
<ItemTemplate>
<asp:TextBox runat="server" ID="txtQuantity" Columns="5" Text='<%# Eval("Quantity") %>'></asp:TextBox><br />
<asp:LinkButton runat="server" ID="btnRemove" Text="Remove" CommandName="Remove" CommandArgument='<%# Eval("ProductId") %>' style="font-size:12px;"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="UnitPrice" HeaderText="Price" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right" DataFormatString="{0:C}" />
<asp:BoundField DataField="TotalPrice" HeaderText="Total" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right" DataFormatString="{0:C}" />
</Columns>
</asp:GridView>
<br />
<asp:Button runat="server" ID="btnUpdateCart" Text="Update Cart" OnClick="btnUpdateCart_Click" />
</div>
</form>
</body>
</html>
Here is the code that is calling the GridView in the ViewCart.aspx.cs file:
protected void BindData() {
// Let's give the data to the GridView and let it work!
// The GridView will take our cart items one by one and use the properties
// that we declared as column names (DataFields)
gvShoppingCart.DataSource = ShoppingCart.Instance.Items;
gvShoppingCart.DataBind();
}
How can I get the ViewCart.aspx.cs code file to recognize the ViewCart.aspx and the GridView contained within?
Edit: Added the function that calls the gridview.
Try to make sure that the gridview has a reference in the designer.cs file
protected global :: System.Web.UI.WebControls.GridView gvShoppingCart;