Hello I have the following problem I tried and nothing , I can not recover my text box user control , the TexBox will use them in the EDIT POPUP
CONVENIO.ASPX
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="convenios.aspx.cs" Inherits="convenios5.convenios" %>
<%# Register TagPrefix="ModalPopup" TagName="detalle" Src="~/UserControls/Popup_conveniodetalle.ascx"%>
<%# Register TagPrefix="ModalPopup" TagName="editar" Src="~/UserControls/Popup_conveniomodificar.ascx"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<link href="Styles/GridStyle.css" rel="stylesheet" type="text/css" />
<%--<link href="Styles/bootstrap.css" rel="stylesheet" type="text/css" />--%>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script>
<link href="http://code.jquery.com/ui/1.11.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<%-- CERRAR DIALOG UI --%>
<script type="text/javascript">
function closeDialog() {
$("#divmodificar").dialog('close');
}
</script>
</head>
<body>
<form id="Form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div class="panel panel-default">
<div class="panel-heading">
<h3>:: CONVENIOS CLINICA CAYETANO ::</h3>
</div>
<div class="panel-body">
<asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table width="100%">
<tr id="trMessage" runat="server" visible="false">
<td>
<asp:Label ID="lblMessage" runat="server" Text="No hay datos que mostar"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:GridView ID="gridconvenios" runat="server" AllowPaging="true" PageSize="5"
CssClass="GridStyle" BorderColor="#cbcbcb" BorderStyle="solid" OnRowCommand="gridconvenios_RowCommand" OnPageIndexChanging="gridconvenios_PageIndexChanging"
BorderWidth="1" AutoGenerateColumns="false" DataKeyNames="COD_CONVENIO" width="100%">
<AlternatingRowStyle CssClass="GridStyle_AltRowStyle" />
<HeaderStyle CssClass="GridStyle_HeaderStyle" />
<RowStyle CssClass="GridStyle_RowStyle" />
<pagerstyle cssclass="GridStyle_pagination" />
<Columns>
<asp:TemplateField HeaderText="CODIGO">
<ItemStyle HorizontalAlign="Center" width="5%" />
<ItemTemplate>
<asp:LinkButton ID="cmddetalle" runat="server" CausesValidation="False" Text='<%# Eval("COD_CONVENIO") %>' CommandName="detalle" CommandArgument='<%# Eval("COD_CONVENIO") %>' ></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ENTIDAD">
<ItemStyle width="20%" />
<ItemTemplate>
<asp:Label ID="lblRequiredDate" runat="server" Text='<%# Eval("DES_IAFA") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CONVENIO">
<ItemStyle HorizontalAlign="Center" width="10%" />
<ItemTemplate>
<asp:Label ID="lblShippedDate" runat="server" Text='<%# Eval("DES_CONVENIO") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="INICIO">
<ItemStyle width="5%" />
<ItemTemplate>
<asp:Label ID="lblShipName" Text='<%# Eval("FEC_INI") %>' runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="FIN">
<ItemStyle width="5%" />
<ItemTemplate>
<asp:Label ID="lblShipAddress" Text='<%# Eval("FEC_INI") %>' runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="FACTOR">
<ItemStyle width="5%" />
<ItemTemplate>
<asp:Label ID="lblfactor" Text='<%# Eval("IMP_FACTORHON") %>' runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ESTADO">
<ItemStyle width="5%" />
<ItemTemplate>
<asp:Label ID="lblestado" Text='<%# Eval("EST_CONVENIO") %>' runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemStyle HorizontalAlign="Center" width="5%" />
<ItemTemplate>
<asp:ImageButton ID="cmdEdit" CommandName="editar" CommandArgument='<%# Eval("COD_CONVENIO")%>' runat="server" ImageUrl="~/images/edit.gif" CausesValidation="False"></asp:ImageButton>
<asp:ImageButton ID="cmdDelete" CommandName="eliminar" CommandArgument='<%# Eval("COD_CONVENIO")%>' runat="server" ImageUrl="~/images/delete.gif" CausesValidation="False"></asp:ImageButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
<div id="divmodificar" style="display:none;">
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<ModalPopup:editar ID="ucmodificar" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="gridconvenios" EventName="RowCommand" />
</Triggers>
</asp:UpdatePanel>
</div>
</div>
</div>
</form>
</body>
</html>
CONVENIOS.ASPX.CS
protected void gridconvenios_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
{
string COD_CONVENIO = Convert.ToString(e.CommandArgument);
switch (e.CommandName.ToLower())
{
case "editar":
System.Text.StringBuilder sb1 = new System.Text.StringBuilder();
sb1.Append("<script type='text/javascript'>");
sb1.Append(" $(\"#divmodificar\").dialog({");
sb1.Append(" title: \"EDITAR CONVENIO: " + COD_CONVENIO + "\",");
sb1.Append("position:'center', width:'auto', autoresize:true, modal:true,");
sb1.Append("open: function(type,data) {");
sb1.Append("$(this).parent().appendTo(\"form\");");
sb1.Append("}");
sb1.Append("});");
sb1.Append("</script>");
var ucmodificar1 = (convenios5.UserControls.Popup_conveniomodificar)ucmodificar;
ucmodificar1.BindOrderDetail(COD_CONVENIO);
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ModalScript1", sb1.ToString(), false);
break;
}
}
CONVENIOEDITAR.ASCX
<asp:Panel ID="Panel1" runat="server">
<fieldset>
<legend>DATOS CONVENIO</legend>
<table width="100%">
<tr>
<td class="cabecera">CÓDIGO: </td>
<td class="texto"><asp:Textbox ID="Text1" runat ="server"></asp:Textbox></td>
</tr>
<tr>
<td class="cabecera">DESCRIPCIÓN: </td>
<td class="texto"><asp:Textbox ID="Text2" runat="server" Width="80%"></asp:Textbox></td>
</tr>
<tr>
<td class="cabecera">FACTOR: </td>
<td class="texto"><asp:Textbox ID="Text3" runat="server" Width="80%"></asp:Textbox></td>
</tr>
<tr>
<td class="cabecera">ESTADO: </td>
<td>
<p>
<asp:RadioButton ID="activo" runat="server" Text="Activo"/>
<asp:RadioButton ID="inactivo" runat="server" Text="Inactivo"/>
</p>
</td>
</tr>
<tr>
<td colspan="2" align="right">
CONVENIOEDITAR.ASCX (HERE PROBLEM)
protected void cmdAdd_Click(object sender, EventArgs e)
{
string VAR1 = this.Text1.Text;// THIS VAR1 IS NULL
}
I can not capture the value of VAR1 appears to me as NULL.
Please help me...
I would use the onClientClick property of the asp:LinkButton, and get the textbox value via jQuery
<asp:LinkButton> .. OnClientClick="GetText1Val();" </asp:LinkButton>
And the function:
<script language="javascript">
function GetText1Val() {
var Text1Value = $("#Text1").val();
alert(Text1Value);
}
</script>
Related
I have a page that displays a GridView containing an ImageButton TemplateField. My goal is to display an AJAX modal popup when one of those buttons are clicked, along with displaying the row where the button is pressed. The problem is that when I click on a button, it does not show the modal popup. I tried to use this tutorial and read several articles on this site about this issue but to no avail. How to properly fire the button event and show the popup?
Here is the snippet for the gridview:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
Width="505px" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="ItemDesc"
SortExpression="ItemDesc" ItemStyle-Width="100px" ItemStyle-Height="100px">
<ItemStyle Height="100px" Width="100px"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="Price" SortExpression="Price"
ItemStyle-Width="100px" ItemStyle-Height="100px">
<ItemStyle Height="100px" Width="100px"></ItemStyle>
</asp:BoundField>
<asp:TemplateField>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Image ID="Image1" runat="server" Height="200px"
ImageUrl='<%# Eval("ImagePath") %>' Width="200px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" CommandName="atc" ImageUrl="~/App_Themes/img/shop/addtocart.png"
Text="Add to Cart" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"/>
</ItemTemplate>
<ControlStyle Height="30px" Width="105px" />
<ItemStyle Width="105px" />
</asp:TemplateField>
</Columns>
</asp:GridView>
...
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="HiddenField1" PopupControlID="Panel1" BackgroundCssClass="modalBg" CancelControlID="btnClose">
</asp:ModalPopupExtender>
<asp:HiddenField ID="HiddenField1" runat="server" />
<asp:Panel ID="Panel1" runat="server" Width="500" Height="500" Visible="False"
style="background-color:#6f95f4; color:#000000;">
<div class="style1">
<br />
<br />
<br />
<br />
<br />
<table style="width: 90%; height: 71px;">
<tr>
<td>
Item Name</td>
<td>
<asp:Label ID="lblItemName" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td>
Price</td>
<td>
<asp:Label ID="lblPrice" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td>
Quantity</td>
<td>
<asp:TextBox ID="TextBox2" runat="server" Type="Number" Min="1" MaxLength="100"
Width="75px" Height="23px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Total Price</td>
<td>
<asp:Label ID="lblTotalPrice" runat="server" Text="Label"></asp:Label>
</td>
</tr>
</table>
<br />
<br />
<asp:Button ID="btnAddToCart" runat="server" Text="Add to Cart"
onclick="btnAddToCart_Click" />
<br />
<br />
<asp:Button ID="btnClose" runat="server" onclick="btnClose_Click" Text="Close"
Width="199px" />
</div>
</asp:Panel>
And here's my code for the event:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("atc"))
{
ModalPopupExtender1.Show();
//// Retrieve the row index stored in the
//// CommandArgument property.
int index = Convert.ToInt32(e.CommandArgument);
//// Retrieve the row that contains the button
//// from the Rows collection.
GridViewRow row = GridView1.Rows[index];
lblItemName.Text = row.Cells[0].Text;
lblPrice.Text = row.Cells[1].Text;
Response.Write("<script>alert('" + row.Cells[0].Text + "\n" + row.Cells[1].Text + "');</script>");
//// Add code here to add the item to the shopping cart.
}
}
EDIT: Added the panel code.
Try like this:
100% working and Tested
Use onrowcommand="GridView1_RowCommand" for GridView
Use display:none for Your Panel instead of Visible="false"
I Commented your alert(in rowbound) it contains js error
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="505px"
onrowcommand="GridView1_RowCommand"
>
<Columns>
<asp:BoundField DataField="ItemDesc" SortExpression="ItemDesc" ItemStyle-Width="100px"
ItemStyle-Height="100px">
<ItemStyle Height="100px" Width="100px"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="Price" SortExpression="Price" ItemStyle-Width="100px"
ItemStyle-Height="100px">
<ItemStyle Height="100px" Width="100px"></ItemStyle>
</asp:BoundField>
<asp:TemplateField>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Image ID="Image1" runat="server" Height="200px" ImageUrl='<%# Eval("ImagePath") %>'
Width="200px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" CommandName="atc"
CausesValidation="false"
Text="Add to Cart" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" />
</ItemTemplate>
<ControlStyle Height="30px" Width="105px" />
<ItemStyle Width="105px" />
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<ajax:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="Panel1"
PopupControlID="Panel1" OnOkScript="okClick();"
OnCancelScript="cancelClick();"
OkControlID="btnAddToCart" CancelControlID="btnClose">
</ajax:ModalPopupExtender>
<asp:HiddenField ID="HiddenField1" runat="server" />
<asp:Panel ID="Panel1" runat="server" Width="500" Height="500"
style="background-color:#6f95f4; color:#000000;display:none">
<div class="style1">
<br />
<br />
<br />
<br />
<br />
<table style="width: 90%; height: 71px;">
<tr>
<td>
Item Name</td>
<td>
<asp:Label ID="lblItemName" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td>
Price</td>
<td>
<asp:Label ID="lblPrice" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td>
Quantity</td>
<td>
<asp:TextBox ID="TextBox2" runat="server" Type="Number" Min="1" MaxLength="100"
Width="75px" Height="23px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Total Price</td>
<td>
<asp:Label ID="lblTotalPrice" runat="server" Text="Label"></asp:Label>
</td>
</tr>
</table>
<br />
<br />
<asp:Button ID="btnAddToCart" runat="server" Text="Add to Cart"
onclick="btnAddToCart_Click" />
<br />
<br />
<asp:Button ID="btnClose" runat="server" onclick="btnClose_Click" Text="Close"
Width="199px" />
</div>
</asp:Panel>
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("atc"))
{
ModalPopupExtender1.Show();
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = GridView1.Rows[index];
ImageButton ImageButton1=(ImageButton)row.FindControl("ImageButton1");
// Response.Write("<script>alert('" + row.Cells[0].Text + "\n" + row.Cells[1].Text + "');</script>"); comment this
}
You didn't set OnRowCommand property of the GridView, so GridView1_RowCommand method won't be fired when you click the image button. Here's how you do it
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
Width="505px" DataSourceID="SqlDataSource1"
OnRowCommand="GridView1_RowCommand">
See here for more details.
I have a data field "Gender" (sql data type - bit).
I have created bound the data with if condition to check true-> male otherwise -> female. But it still does not display.
Here is the aspx and code behind code:The gridview shows true/false instead of male/female:
<%# Page Title="Add User" Language="C#" AutoEventWireup="true" CodeFile="adduser.aspx.cs" Inherits="_Default" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<!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 id="Head1" runat="server">
<title></title>
<link href="style.css" type="text/css" rel="Stylesheet" />
<script type="text/javascript">
function confirmDelete() {
return confirm("Do you want to delete this record?");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<ajax:ToolkitScriptManager ID="toolkit1" runat="server">
</ajax:ToolkitScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table border="0" align="center" cellpadding="2" cellspacing="2" class="maindiv">
<tr><!--Hidden field for EmployeeID reference-->
<td colspan="2"><asp:HiddenField ID="txtHiddenEmpID" Value="0" runat="server" /></td>
</tr>
<tr>
<td>
<span class="asterisk">*</span><asp:Label ID="name" runat="server" Text="Name"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtEmpName" runat="server" CssClass="box"></asp:TextBox>
<asp:RequiredFieldValidator Display="None" ID="RequiredFieldValidator1" ErrorMessage="Name is required!"
EnableClientScript="true" SetFocusOnError="true" runat="server" ControlToValidate="txtEmpName"
CssClass="error_msg"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="NameValidator" runat="server" ErrorMessage="Name can not contain numeric or special characters."
ControlToValidate="txtEmpName" ValidationExpression="^[A-Za-z ]*$" CssClass="error_msg"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
<span class="asterisk">*</span><asp:Label ID="Label1" runat="server" Text="Address"></asp:Label>
</td>
<td>
<asp:TextBox ID="addressBox" runat="server" CssClass="box"></asp:TextBox>
<asp:RequiredFieldValidator Display="None" ID="AddressValidator" ErrorMessage="Address is required!"
EnableClientScript="true" SetFocusOnError="true" runat="server" ControlToValidate="addressBox"
CssClass="error_msg"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<span class="asterisk">*</span><asp:Label ID="Label2" runat="server" Text="DOB"></asp:Label>
</td>
<td>
<asp:TextBox ID="dobBox" runat="server" CssClass="dob_cal box" ReadOnly="false" ></asp:TextBox>
<ajax:CalendarExtender ID="CalenderExtender1" TargetControlID="dobBox" Format="dd/MM/yyyy"
runat="server">
</ajax:CalendarExtender>
<asp:RequiredFieldValidator Display="None" ID="dobValidator" ErrorMessage="DOB is required!"
EnableClientScript="true" SetFocusOnError="true" runat="server" ControlToValidate="dobBox"
CssClass="error_msg"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<span class="asterisk">*</span><asp:Label ID="Label3" runat="server" Text="Salary"></asp:Label>
</td>
<td>
<asp:TextBox ID="salaryBox" runat="server" CssClass="box" MaxLength="8" ></asp:TextBox>
<asp:RequiredFieldValidator ID="salaryValidate" runat="server" ControlToValidate="salaryBox"
ErrorMessage="Salary is required!" Display="None" CssClass="error_msg" SetFocusOnError="true"
EnableClientScript="true"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="SalaryValidator" runat="server" ErrorMessage="Salary can contain only numeric values."
Display="None" ControlToValidate="salaryBox" ValidationExpression="^[0-9]*$"
CssClass="error_msg"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
<span class="asterisk">*</span><asp:Label ID="gender" runat="server" Text="Gender"></asp:Label>
</td>
<td>
<span>
<asp:RadioButton GroupName="gendergrp" ID="gendermale" runat="server" Text="Male"
Checked="true" /></span><span style="padding-left: 5px;">
<asp:RadioButton GroupName="gendergrp" ID="genderfemale" runat="server" Text="Female"
Checked="false" /></span>
</td>
</tr>
<tr>
<td>
<div style="float: right; margin-right: -70px;">
<asp:Button ID="Button1" runat="server" CssClass="btn" Text="Save" OnClick="Button1_Click" /></div>
</td>
<td>
<div style="float: left; margin-left: 70px;">
<asp:Button ID="CancelBtn" CausesValidation="false" runat="server" CssClass="btn"
Text="Cancel" OnClick="CancelBtn_Click" />
</div>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="lblError" runat="server" CssClass="error_msg"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
<asp:ValidationSummary ID="valSum" DisplayMode="BulletList" EnableClientScript="true"
HeaderText="Error!" runat="server" CssClass="error_msg" />
</td>
</tr>
</table>
<!--div for data display-->
<div class="data_display">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
DataKeyNames="EmployeeID" EmptyDataText="There are no data records to display."
GridLines="Horizontal" BackColor="#CCCCCC" BorderColor="White" Font-Bold="False"
Font-Names="Arial" Font-Size="Medium" ForeColor="#666666"
AllowPaging="True" PageSize="5" PagerSettings-Mode="Numeric"
PagerSettings-Position="Bottom"
onpageindexchanging="GridView1_PageIndexChanging"
>
<Columns>
<%-- <asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="EmpID" runat="server" Value='<%# Eval("EmployeeID") %>' />
</ItemTemplate>
</asp:TemplateField>
--%> <asp:BoundField DataField="EmployeeID" HeaderText="Employee ID"
SortExpression="EmployeeID" Visible="true" ItemStyle-HorizontalAlign="Center">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="EmployeeName" HeaderText="Name" SortExpression="EmployeeName"
ItemStyle-Width="130px" ItemStyle-HorizontalAlign="Center">
<ItemStyle HorizontalAlign="Center" Width="130px" />
</asp:BoundField>
<asp:BoundField DataField="DateOfBirth" HeaderText="DoB" SortExpression="DateOfBirth"
DataFormatString="{0:dd-MM-yyyy}" ItemStyle-Width="100px" ItemStyle-HorizontalAlign="Center">
<ItemStyle HorizontalAlign="Center" Width="100px" />
</asp:BoundField>
<asp:BoundField DataField="Salary" HeaderText="Salary"
SortExpression="Salary">
<ItemStyle HorizontalAlign="Center" Width="90px" />
</asp:BoundField>
<asp:BoundField DataField="Gender" HeaderText="Gender" ItemStyle-Width="90px"
ItemStyle-HorizontalAlign="Center">
<ItemStyle HorizontalAlign="Center" Width="70px" />
</asp:BoundField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="EditBtn" runat="server" Text="Select" CausesValidation="false" OnClick="EditBtn_Click" />
<asp:Button ID="DelBtn" runat="server" Text="Delete" CausesValidation="false" OnClick="DelBtn_Click" OnClientClick="confirmDelete()" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#ffffff" />
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="Gray" Font-Bold="false" ForeColor="White" />
<PagerStyle BackColor="Gray" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#E3EAEB" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F8FAFA" />
<SortedAscendingHeaderStyle BackColor="#246B61" />
<SortedDescendingCellStyle BackColor="#D4DFE1" />
<SortedDescendingHeaderStyle BackColor="#15524A" />
</asp:GridView>
<br />
<span style="font-family: Arial; font-size: small; color: Green; font-weight: bold;">
You are viewing page <%=GridView1.PageIndex + 1%> of <%=GridView1.PageCount%>
</span>
</div>
<div>
<asp:Label ID="lblMessage" runat="server"></asp:Label></div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
**code behind:**
#region GridView Functions
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[4].Text == "True")
{
e.Row.Cells[4].Text = "Male";
}
else
{
e.Row.Cells[4].Text = "Female";
}
}
}
#endregion
The gridview Gender column shows true/false instead of male/female.
Thanks!
You need a TemplateField for this. Assuming Male equates to True, this should work:
<asp:TemplateField HeaderText="Gender" SortExpression="Gender">
<ItemTemplate><%# (Boolean.Parse(Eval("Gender").ToString())) ? "Male" : "Female" %></ItemTemplate>
</asp:TemplateField>
I have a master page and their is script manager with update panel inside it. . now i am trying to add update panel in content page without using script manager but it gives me an error:
The control with ID 'updpanel' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.
I know i can use only one instance of script manager, then i tried ScriptManagerProxy but it gives me the error that scriptMangerProxy requires script manager.
I also tried ajax:ToolScriptManager but it also gives the same results
So the question is how can make the update panel to work in content page..
Master Page:
<%# Master Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="SideMaster.master.cs" Inherits="SideMaster" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" type="text/jscript"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#chit').scrollTop(1000000);
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="sidemenu">
<asp:SiteMapDataSource ID="topNav" runat="server" />
<asp:Menu ID="SideMenu" runat="server" DataSourceID="topNav" CssClass="SideMenu" StaticDisplayLevels="4"
Font-Bold="true" Font-Size="20" IncludeStyleBlock="true" >
<StaticMenuItemStyle VerticalPadding="5" BackColor="#670a0a" ForeColor="White" HorizontalPadding="5" />
<StaticSelectedStyle BackColor="White" ForeColor="#670a0a" />
</asp:Menu>
</div>
<div class="cont3" >
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<div class="rightmenu">
<div class="newspan">
<asp:Repeater ID="RepNews" runat="server" >
<HeaderTemplate><div class="newsheadcont">News & Events</div></HeaderTemplate>
<ItemTemplate>
<div class="newstemp">
<hr />
# <%#Eval("News") %>
<asp:LinkButton ID="LinkNews" runat="server" CssClass="welcomeMore"></asp:LinkButton>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
<br /><br />
<div class="chatcont" style="margin-left:1%;">
<div class="chat">
<h2 class="chathead">Peoples Talking About </h2>
<asp:ScriptManager ID="scmang" runat="server"></asp:ScriptManager>
<%--<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</ajaxToolkit:ToolkitScriptManager>--%>
<script type="text/javascript">
var xPos, yPos;
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args) {
xPos = $get('chit').scrollLeft;
yPos = $get('chit').scrollTop;
}
function EndRequestHandler(sender, args) {
$get('chit').scrollLeft = xPos;
$get('chit').scrollTop = yPos;
}
</script>
<asp:UpdatePanel ID="updPanelChat" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional" >
<ContentTemplate>
<asp:Panel ID="pan" runat="server">
<asp:ListView ID="ListChat" runat="server" >
<LayoutTemplate>
<div class="chattemp" style="width:250px; " id="chit" >
<asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
</div>
</LayoutTemplate>
<ItemSeparatorTemplate><hr /></ItemSeparatorTemplate>
<EmptyDataTemplate>No Data Found</EmptyDataTemplate>
<ItemTemplate>
<div class="chatbox" >
<div class="chatpic" style="margin:18px 0px 0px 0px;" >
<asp:ImageButton ID="ImageChat" runat="server"
ToolTip='<%#Eval("UserName") %>'
ImageUrl='<%# "~/ShowImage.ashx?Name=" + Server.UrlEncode(Eval("UserName").ToString()) %>'
PostBackUrl='<%#"~/Profile/Profile.aspx?Name="+Eval("UserName") %>'
Width="50" Height="50" />
</div>
<div class="chatbubble" style="width:160px; margin:-50px 5px 5px 60px; float:left;">
<asp:Label ID="LabelChat" runat="server" Width="100" Height="50"><%#Eval("Body") %></asp:Label>
</div>
<div class="chatname" style="width:50px; border:none;" >
<asp:LinkButton ID="LinkUserName" runat="server"
PostBackUrl='<%#"~/Profile/Profile.aspx?Name="+Eval("UserName") %>'><%#Eval("UserName") %></asp:LinkButton>
</div>
</div>
</ItemTemplate>
</asp:ListView>
<asp:Timer ID="TimerUpdate" runat="server" Interval="20000"
ontick="TimerUpdate_Tick"></asp:Timer>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<div class="messagebox" style="width:250px; height:120px; border:none;">
<asp:TextBox ID="TextBoxMessage" runat="server" TextMode="MultiLine" Visible="false" Width="250" Height="80" MaxLength="500"></asp:TextBox>
<asp:Button ID="ButtonMessage" runat="server" Text="Comment"
onclick="ButtonMessage_Click" Visible="false" />
</div>
</div>
</div>
</div>
</asp:Content>
Content Page:
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="interface" >
<table>
<tr>
<td align="center">
<div class="goog">
<asp:LinkButton ID="LinkFind" runat="server" CssClass="linkgoog">Find</asp:LinkButton>
</div>
</td></tr>
<tr><td align="left">
<div>
<asp:TextBox ID="TextBoxSearch" runat="server" Width="600" Height="40"></asp:TextBox>
<asp:Button ID="ButtonSearch" runat="server" Text="SEARCH" CssClass="loginbt"
onclick="ButtonSearch_Click1" /><br />
</div>
</td></tr>
</table>
</div>
<br />
<div class="interface">
<asp:UpdatePanel ID="updpanel" runat="server">
<ContentTemplate>
<asp:GridView ID="GridAll" runat="server"
onitemcommand="GridAll_ItemCommand" AutoGenerateColumns="false" CellPadding="10" AllowPaging="true" PageSize="3" OnPageIndexChanging="GridAll_PageIndexChanging" >
<Columns>
<asp:TemplateField HeaderText="Name" HeaderStyle-BackColor="#670a0a" HeaderStyle-ForeColor="White" HeaderStyle-Font-Size="20">
<ItemTemplate>
<asp:LinkButton ID="lnkname" runat="server"
Text='<%#Eval("Name") %>'
PostBackUrl='<%#"~/Profile/Profile.aspx?Name="+Eval("UserName") %>' CssClass="welcomeMore"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Department" HeaderStyle-BackColor="#670a0a" HeaderStyle-ForeColor="White" HeaderStyle-Font-Size="20" >
<ItemTemplate>
<span class="googtext"><%#Eval("Department") %></span>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Year" HeaderStyle-BackColor="#670a0a" HeaderStyle-ForeColor="White" HeaderStyle-Font-Size="20">
<ItemTemplate>
<span class="googtext"><%#Eval("Year") %></span>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Photo" HeaderStyle-BackColor="#670a0a" HeaderStyle-ForeColor="White" HeaderStyle-Font-Size="20">
<ItemTemplate>
<asp:Image ID="ImageProfile" runat="server" ImageUrl = '<%# "~/ShowImage.ashx?Name=" + Server.UrlEncode(Eval("UserName").ToString()) %>' Width="150" Height="150" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<div class="emptytext">No Match Found</div>
</EmptyDataTemplate>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Content>
Your help will be appreciated. . . Thank you
You should have only one script manager in master page above update panel.
In any of the content page you can use update panel as there is already script manager in master page. Also you should provide some code for your problem.
I have a ASP.NET application for list all search User in a ListView in "BenutzerListe.aspx". A client user can select a User and show that user's Properties in an extra Web Form, named "benutzer.aspx". In "Benutzer.aspx", the user can change these Properties.
I want show this informations, not in a second Web Form, but in a Dialog, create by jQuery. I hear that I can input my "Benutzer.aspx" in the dialog.
How I can do this?
My Idea:
aspx:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="~/BenutzerListe.aspx.cs" Inherits="BenutzerListe.BenutzerListe" %>
<!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></title>
<script src="Scripte/jquery-1.7.2.js" type="text/javascript"></script>
<link href="~/App_Theme/BenutzerListeStyle.css" type="text/css" rel="Stylesheet" />
<style type="text/css">
#SuchTabelle
{
width: 587px;
}
</style>
<script type="text/javascript">
$(document).ready(function () {
$("#Button2").click(function (event) {
//How I open a Dialog with Benutzer.aspx
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div class="header">
<table id="SuchTabelle" runat="server" border="0">
<tr>
<th><asp:Label ID="id_SearchUser" runat="server" Text="lblSearchUser"></asp:Label></th>
<th><asp:TextBox ID="txtBenutzer" runat="server" Width="250px"></asp:TextBox></th>
</tr>
<tr>
<th><asp:Label ID="id_location" runat="server" Text="lblLocation"></asp:Label></th>
<th><asp:DropDownList ID="dropWerk" runat="server" Width="250px" /></th>
<th><asp:Button ID="Button2" runat="server" Text="Suchen"
onclick="btnBenutzerSuchen_Click" Width="219px" /></th>
</tr>
</table>
<div id="bild">
<asp:Image runat="server" ImageUrl="~/App_Theme/lw_logo.jpg" Height="58px"
Width="277px" />
</div>
<div id="meldung">
<asp:Label runat="server" ID="lblMeldung"></asp:Label>
</div>
</div>
<div class="bodyList">
<asp:ListView runat="server" ID="myListView">
<LayoutTemplate>
<table id="UserTable" runat="server" border="0" width="800" cellpadding="0" cellspacing="0">
<tr style="background-color:#E5E5FE" class="TableClass">
<th id="th1" runat="server"><asp:LinkButton ID="lnkBenutzer" runat="server" >id_Benutzer</asp:LinkButton></th>
<th id="th2" runat="server"><asp:LinkButton ID="lnkemail" runat="server" >id_Email</asp:LinkButton></th>
<th id="th3" runat="server"><asp:LinkButton ID="lnkVorname" runat="server" >id_Vorname</asp:LinkButton></th>
<th id="th4" runat="server"><asp:LinkButton ID="lnkNachname" runat="server" >id_Nachname</asp:LinkButton></th>
<th id="th5" runat="server"><asp:LinkButton ID="lnkTelefon" runat="server" >id_Telefon</asp:LinkButton></th>
</tr>
<tr runat="server" id="ItemPlaceholder">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr class="TableClass">
<td align="left" ><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label1" Text='<%# Eval("Benutzername") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label2" Text='<%# Eval("eMail") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label3" Text='<%# Eval("Vorname") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label4" Text='<%# Eval("Nachname") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label5" Text='<%# Eval("Telefonnummer") %>' runat="server" /></td>
<td align="left"><asp:Label ID="Label6" Text='<%# Eval("GUID") %>' runat="server" Visible="False" /></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr class="TableClass">
<td align="left" ><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label1" Text='<%# Eval("Benutzername") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label2" Text='<%# Eval("eMail") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label3" Text='<%# Eval("Vorname") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label4" Text='<%# Eval("Nachname") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label5" Text='<%# Eval("Telefonnummer") %>' runat="server" /></td>
<td align="left"><asp:Label ID="Label6" Text='<%# Eval("GUID") %>' runat="server" Visible="False" /></td>
</tr>
</AlternatingItemTemplate>
</asp:ListView>
<br />
<br />
</div>
</form>
</body>
</html>
Try if this helps:
http://msdn.microsoft.com/en-us/library/ie/ms536759(v=vs.85).aspx
You could do something as simple with the JQUERY UI dialog:
In your page:
<div id="dialog">
<iframe src="Benutzer.aspx"></iframe>
</div>
In your jquery function:
$(document).ready(function () {
$("#Button2").click(function (event) {
$( "#dialog" ).dialog();
});
I Have the below Asp.net Code:
the problem is that When Timer Tick Every 30 Second and GridView Filled the javascript code is not executed !! and Sound is not played.
I have also tried SoundPlayer Class but is not working on the Server Side can anyone provide me with a solution ?
<%# Page Language="C#" AutoEventWireup="true" CodeFile="OrdersPage.aspx.cs" Inherits="Orders_" Async="true" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!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>Gazar | Orders Page</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<link rel="Stylesheet" href="StyleSheet.css" />
<script type="text/javascript">
function ShowProgress() {
document.getElementById('UpdateProgress1').style.display = "inline";
}
</script>
</head>
<body>
<form id="form1" class="center_it" runat="server">
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" EnablePageMethods="true" runat="server"></asp:ToolkitScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
<table class="MainTable">
<tr>
<td style="text-align: left;" colspan="2">
<img id="Img2" src="~/images/gazzarlogo.png" alt="GazarBanner" runat="server" class="BannerImage" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="30pt" ForeColor="White"
Text="الطلبـــــات"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click1" Text="History" CssClass="Buttons" />
</td>
<td>
<asp:Button ID="Exit" Text="خروج" runat="server" OnClick="Exit_Click" CssClass="Buttons" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:GridView ID="GridViewOrders" runat="server" Style="margin-left: auto; margin-right: auto;"
OnRowDataBound="GridViewOrders_RowDataBound" PageSize="30" BackColor="White"
BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="0px" CaptionAlign="Top"
CellPadding="4" ForeColor="Black" HorizontalAlign="Center" EnableModelValidation="True"
GridLines="Vertical" Width="1100px" Font-Names="Tahoma" Font-Size="10pt" Font-Bold="False"
OnRowCommand="GridViewOrders_RowCommand" AutoGenerateColumns="False">
<RowStyle BackColor="#F7F7DE" Wrap="True" />
<AlternatingRowStyle BackColor="White" />
<FooterStyle BackColor="#CCCC99" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:TemplateField HeaderText="Open" ItemStyle-Width="60px">
<ItemTemplate>
<asp:Button ID="ApproveBtn" Text="Open" Width="60" Height="30" runat="server" OnClientClick="ShowProgress()" />
</ItemTemplate>
<ItemStyle Width="70px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="ID" ItemStyle-Width="70px">
<ItemTemplate>
<asp:Label ID="OrderID" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "ID") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="70px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Name" ItemStyle-Width="150px">
<ItemTemplate>
<asp:Label ID="Name" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "Name") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="150px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Address" ItemStyle-Width="300px">
<ItemTemplate>
<asp:Label ID="Address" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "Address") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="300px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Number" ItemStyle-Width="100px">
<ItemTemplate>
<asp:Label ID="Number" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "Number") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="100px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Sent Date" ItemStyle-Width="100px">
<ItemTemplate>
<asp:Label ID="SentDate" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "Sent Date") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="100px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Recieved Date" ItemStyle-Width="100px">
<ItemTemplate>
<asp:Label ID="RecievedDate" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "Recieved Date") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="100px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="# Success" ItemStyle-Width="50px">
<ItemTemplate>
<asp:Label ID="SuccessNo" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "# Success") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="50px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="# Fake" ItemStyle-Width="50px">
<ItemTemplate>
<asp:Label ID="FakeNo" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "# Fake") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="50px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Restaurant" ItemStyle-Width="50px">
<ItemTemplate>
<asp:Label ID="Restaurant" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "Restaurant") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="50px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Branch" ItemStyle-Width="50px">
<ItemTemplate>
<asp:Label ID="Branch" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "Branch") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="50px" />
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<div class="container">
<div class="LoadingDiv">
<span class="LoadingLabel">Check Orders ...</span>
<img class="LoadingImg" src="Images/ajax-loader.gif" alt="Loading ..." />
</div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:Timer ID="Timer1" runat="server" Interval="30000" OnTick="Timer1_Tick" />
</form>
</body>
</html>
and code behind is:
protected void Timer1_Tick(object sender, EventArgs e)
{
orderDB.LogState("Time Tick");
if (Session["UserID"] != null)
{
orderDB.LogState("Session Alive");
FillDataGrid(int.Parse(Session["UserID"].ToString()));
orderDB.LogState("End fill Grid View");
}
else
{
Response.Redirect("~/login.aspx");
}
}
private void FillDataGrid(int UserID)
{
Orders = orderDB.GetOrdersByUser(UserID);
orderDB.LogState("Select: " + DateTime.Now.ToString() + "\t" + Request.UserHostAddress + "\t" + Session.SessionID + "\t" + Session["UserID"].ToString());
if (Orders == null)
Response.Redirect("~/login.aspx");
DataTable Table = new DataTable();
Table.Columns.Add("ID", System.Type.GetType("System.String"));
Table.Columns.Add("Name", System.Type.GetType("System.String"));
Table.Columns.Add("Address", System.Type.GetType("System.String"));
Table.Columns.Add("Number", System.Type.GetType("System.String"));
Table.Columns.Add("Sent Date", System.Type.GetType("System.String"));
Table.Columns.Add("Recieved Date", System.Type.GetType("System.String"));
Table.Columns.Add("# Success", System.Type.GetType("System.String"));
Table.Columns.Add("# Fake", System.Type.GetType("System.String"));
Table.Columns.Add("Restaurant", System.Type.GetType("System.String"));
Table.Columns.Add("Branch", System.Type.GetType("System.String"));
for (int i = 0; i < Orders.Count; i++)
{
object[] myRow = new object[10];
myRow[0] = Orders[i].GetId();
myRow[1] = Orders[i].GetOwner();
myRow[2] = Orders[i].GetAddress().getAllAddress();
myRow[3] = Orders[i].GetPhoneNumber();
myRow[4] = Orders[i].GetOriginalTime().ToString();
myRow[5] = Orders[i].GetTime().ToString();
myRow[6] = Orders[i].NoOfSuccess; //success Orders;
myRow[7] = Orders[i].NoOfFake; //fake Orders
myRow[8] = Orders[i].GetResName();
myRow[9] = Orders[i].GetBranchName();
Table.Rows.Add(myRow);
}
orderDB.LogState("Table Rows Count: " + Table.Rows.Count);
GridViewOrders.DataSource = Table;
GridViewOrders.DataBind();
string sSelectedAudio = Server.MapPath("home.wav");
if (GridViewOrders.Rows.Count != 0)
{
playSound(sSelectedAudio);
orderDB.LogState("Sound Played: " + GridViewOrders.Rows.Count);
}
else
{
orderDB.LogState("Empty Grid View: " + GridViewOrders.Rows.Count);
}
}
private void playSound(string path)
{
string PlaySound = "<embed src=\"" + path + "\" autostart=\"true\" hidden=\"true\"></embed>";
Response.Write(PlaySound);
}
It could be the Response.Write that's causing the issue. Try using a placeholder control then adding a HtmlGenericControl to it with the markup for the embed tag i.e.
HtmlGenericControl sound = new HtmlGenericControl("<embed src=\"" + path + "\"
autostart=\"true\" hidden=\"true\"></embed>");
ucPlaceHolder.Controls.Add(sound);
Make sure the placeholder control is withing the ContentTemplate of the UpdatePanel that you are using