Exporting from c#.net
I am getting a problem I have a form that when I export to excel as a result in excel Any ideas why is this happening I am including the ASP code below.
<%# Page Language="C#" MasterPageFile="~/masterpages/Admin.master" AutoEventWireup="true" CodeFile="members-search-adv.aspx.cs" Inherits="masteradmin_members_search_adv" Title="LISA - Life Insurance Settlement" %>
<%# Register TagPrefix="UC" TagName="Paging" Src="~/controls/Paging.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script type="text/javascript" src="sorttable.js"></script>
Go to Quick Search
<h1>Contact Database - Advanced Search</h1>
<asp:Label ID="lblSearchCriteria" runat="server" Text="" ForeColor="blue"></asp:Label>
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" width="50%">
<table border="0" cellpadding="3" cellspacing="1" style="height: 214px; width: 101%;">
<tr>
<td class="form1" align="right"><strong>OpenSearch:</strong></td>
<td class="form2">
<asp:TextBox ID="txtSearch" runat="server" CssClass="fields" Width="245px" ></asp:TextBox><b>*</b> <br><b>*</b><small>Search By Company Name, First Name, Last Name, Tags, Comments</small></td>
</tr>
<tr>
<td class="form1" align="right"><strong>Industry Segment:</strong></td>
<td class="form2"><asp:DropDownList ID="ddlIndSegment" runat="server" CssClass="fields" /></td>
</tr>
<tr>
<td class="form1" align="right"><strong>Member Type:</strong></td>
<td class="form2"><asp:DropDownList ID="ddlMemberType" runat="server" CssClass="fields" /></td>
</tr>
<tr>
<td class="form1" align="right"><strong>Member Rep only:</strong></td>
<td class="form2"><asp:CheckBox ID="cbxMemberRep" runat="server" /></td>
</tr>
<tr>
<td class="form1" align="right"><strong>Board Only:</strong></td>
<td class="form2"><asp:CheckBox ID="cbxBoardOnly" runat="server" /></td>
</tr>
<tr>
<td colspan="2" align="right">
<asp:ImageButton ID="btnSearch" runat="server" ImageUrl="/RadControls/images/bu_search.jpg" />
</td>
</tr>
</table>
</td>
<td> </td>
<td valign="top" width="50%">
<%--split the table here--%>
<table border="0" cellpadding="3" cellspacing="1"
style="width: 98%; margin-left: 0px;">
<tr>
<td class="form1" align="right"><strong>Suspended Only:</strong></td>
<td class="form2"><asp:CheckBox ID="cbxSuspended" runat="server" /></td>
</tr>
<tr>
<td class="form1" align="right"><strong>Active Only:</strong></td>
<td class="form2"><asp:CheckBox ID="cbxActiveOnly" runat="server" /></td>
</tr>
<tr>
<td class="form1" align="right"><strong>Allow Other Members To See My Info Only:</strong></td>
<td class="form2"><asp:CheckBox ID="cbxAllowOtherMembers" runat="server" /></td>
</tr>
<tr>
<td class="form1" align="right"><strong>State:</strong></td>
<td class="form2"><asp:DropDownList ID="ddlState" runat="server" CssClass="fields" /></td>
</tr>
<tr>
<td class="form1" align="right"><strong>By Special Level:</strong></td>
<td class="form2"><asp:DropDownList ID="ddlSpecialLevel" runat="server" CssClass="fields" /></td>
</tr>
<tr>
<td class="form1" align="right"><strong>Sort by:</strong></td>
<td class="form2">
<asp:DropDownList ID="ddlSortBy" runat="server" CssClass="fields">
<asp:ListItem Value="CompanyName">Company</asp:ListItem>
<asp:ListItem Value="FirstName">First Name</asp:ListItem>
<asp:ListItem Value="LastName">Last Name</asp:ListItem>
<asp:ListItem Value="MemberCategoryId">Membership Type</asp:ListItem>
<asp:ListItem Value="IndustrySegmentId">Industry Segment</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table border="0" cellpadding="3" cellspacing="1" width="100%">
<tr>
<td><asp:Literal ID="litTotalCount" runat="server" /></td><td align=left class="form3">
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">Export To Excel</asp:LinkButton>
<small>* Click on the column to SORT</small></td></tr>
</table>
<asp:Repeater ID="rptList" runat="server">
<HeaderTemplate>
<table class="sortable" border="0" cellpadding="3" cellspacing="1" width="100%">
<tr>
<td align="left" valign="top" class="form1"><b>Company</b></td>
<td align="left" valign="top" class="form1"><b>First Name</b></td>
<td align="left" valign="top" class="form1"><b>Last Name</b></td>
<td align="left" valign="top" class="form1"><b>Email</b></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td class="form2" align="left" valign="top"><asp:HyperLink ID="hlCompany" runat="server" CssClass="link"></asp:HyperLink></td>
<td class="form2" align="left" valign="top"><asp:HyperLink ID="hlFirstName" runat="server" CssClass="link"></asp:HyperLink></td>
<td class="form2" align="left" valign="top"><asp:HyperLink ID="hlLastName" runat="server" CssClass="link"></asp:HyperLink></td>
<td class="form2" align="left" valign="top"><asp:HyperLink ID="hlEmail" runat="server" CssClass="link"></asp:HyperLink> </td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<asp:GridView ID="GridView2" runat="server">
</asp:GridView>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"><br />
<UC:Paging Id="ctlPaging" runat="server" />
</asp:PlaceHolder>
<%-- <div align="center">
<br /><UC:Paging Id="ctlPaging" runat="server" />
</div>--%>
</asp:Content>
Sorry but this is a better explanation of the issue
Exporting from c#.net I am getting a problem I have a form that when I export to excel I ge the following <div></div> I have data in the datagrid but not in excel I am just getting <div></div>
And this is the function that I am using
void ExportToExcel3()
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
GridView2.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
}
I am populating the datagrid prior to the export. This is the line of code. It's funny I create a new webform just with this section of code and the export worked.
Do you think there's a problem with the datarepeater that I have in the page that is causing the conflict.
MemberList list = MemberDB.GetMembers(sql, m_page, m_RecordPerPage, out count, _state);
this.GridView2.DataSource = list;
this.GridView2.DataBind();
That's not the sequence at all- it's just not how asp.net and the web work.
You don't fill the grid during the load phase: you retrieve the data and set it as the datasource for the table, but the grid (actually a repeater) isn't filled yet. That doesn't happen until the databinding phase. After the databinding phase (during the render phase) the page with the databound repeater is finally sent by the server to the browser. At this point all your server-side stuff is disposed.
Now the browser can finally show the page with the big "Export to Excel" button which the user can click. Again: the server is already destroying all the data you worked so hard to build. When the user clicks your button, a brand new request is created and a brand new page will be sent back to the browser. You have to load all your data into the grid again.
I found the solution to my problem. Thank you all for contributing. On the Load_Page Event I had the binding inside of an if !postback.
Related
I am fairly new to ASP.NET and I am trying to add the number i created in the backend to be inserted into
the label text field in the front-end but Im not being able to access the Label (lblAmountNumber) inside the Repeater i guess it is not allowing me to access the ID=lblAmountNumber
and the name of my repeater is RpMember
I have my simple code down below
FRONT END
<asp:Repeater ID="RpMember" runat="server">
<HeaderTemplate>
<table id="example1" class="table table-bordered table-hover">
<thead>
<tr>
<th style="min-width: 100px">
<asp:Label ID="Label2" runat="server" Text="MemberInfo"></asp:Label></th>
<th style="min-width: 100px">
<asp:Label ID="Label3" runat="server" Text="Amount Number"></asp:Label></th>
<th style="min-width: 100px">
<asp:Label ID="Label5" runat="server" Text="Loan Balance"></asp:Label></th>
<th style="min-width: 100px">
<asp:Label ID="Label1" runat="server" Text="Savings Balance"></asp:Label></th>
<th style="min-width: 100px" class="ButtonView">
<asp:Label ID="Label6" runat="server"></asp:Label></th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr style="text-align: center">
<td style="width: 100px; text-align: left; text-transform: capitalize"><%#Eval("Name") %>
<br />
<%#Eval("Phone") %>
<br />
<%#Eval("Address") %>
</td>
<td style="width: 100px"><asp:Label ID="lblAmountNumber" runat="server"></asp:Label></th></td>
<td style="width: 100px"><%#Eval("LoanBalance") %></td>
<td style="width: 100px"><%#Eval("SavingsBalance") %></td>
<td style="text-align: center; width: 100px" class="ButtonView">
<asp:LinkButton ID="ReportLinkBtn" runat="server" OnClick="ReportLinkBtn_Click" CommandArgument='<%# Eval("MemberId")%>' CssClass="btn btn-success" Text="Report Details" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
</FooterTemplate>
</asp:Repeater>
BACKEND
DataTable dt2 = objdalTransactionEntry.GetLoanTakerStartAmountByLoanTakerId(Sessions.Name.UserId, MemberId);
foreach (RepeaterItem item in RpMember.Items)
{
Label lab = item.FindControl("lblHishabNumber") as Label;
string yearForHishabNumber = Convert.ToDateTime(dt2.Rows[0]["EntryDate"].ToString()).Year.ToString();
string monthForHishabNumber = Convert.ToDateTime(dt2.Rows[0]["EntryDate"].ToString()).ToString("MM");
string yearForInvoiceNumber = Convert.ToDateTime(dt2.Rows[0]["EntryDate"].ToString()).Year.ToString();
string monthForInvoiceNumber = Convert.ToDateTime(dt2.Rows[0]["EntryDate"].ToString()).ToString("MM");
string dayForInvoiceNumber = Convert.ToDateTime(dt2.Rows[0]["EntryDate"].ToString()).ToString("dd");
lab.Text = "Amount Number " + monthForHishabNumber + yearForHishabNumber.Substring(yearForHishabNumber.Length - 2) + dt2.Rows[0]["UserWiseID"].ToString();
}
I have a table within my aspx page content page (using a Master Page also)
The problem is the Timer doesn't seem to be doing the async postback it doesnt even hit the method
I've tried a fresh solution in VS with the below code and it works fine every 10 seconds the event updatepanel is refreshed. So I believe the code is fine but there's something stopping this from working and I can't figure what.
<div class="row" >
<div class="col-md-3">
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<asp:Triggers>
<asp:AsyncPostBackTrigger ControlID="TimerPrayer"></asp:AsyncPostBackTrigger>
</asp:Triggers>
<ContentTemplate>
<table id="tblPrayerTimes" class="table-condensed">
<tr>
<th colspan="3">
<asp:Label ID="LblPrayer" runat="server" CssClass="prayerTimeHeaderscss" Text="Prayer Time"></asp:Label>
</th>
<th colspan="1">
<asp:Label ID="lblJammat" runat="server" CssClass="prayerTimeHeaderscss" Text="Jamaat Time"></asp:Label>
</th>
</tr>
<tr>
<td></td>
<th>
<asp:Label ID="lblToday" runat="server" CssClass="prayerlabeltodaytomorrowcss" Text="Today"></asp:Label>
</th>
<th>
<asp:Label ID="lblTomorrow" runat="server" CssClass="prayerlabeltodaytomorrowcss" Text="Tomorrow"></asp:Label>
</th>
</tr>
<tr>
<td>
<asp:Label ID="lblFajr" runat="server" CssClass="prayerLabelscss" Text="Fajr"></asp:Label>
</td>
<td style="text-align: center">
<asp:Label ID="lblbegFajrTime" runat="server" CssClass="prayerTimescss" Text="00:00"></asp:Label>
</td>
<td style="text-align: center">
<asp:Label ID="lbltmrwFajrTime" runat="server" CssClass="prayerTimeTmrwcss" Text="00:00"></asp:Label>
</td>
<td id="tdfajrJamaatbox" style="text-align: center">
<asp:TextBox ID="txtFajrJamaat" runat="server" Text="00:00" onmousedown="displayPicker('Fajr','tdfajrJamaatbox');" MaxLength="5" CssClass="prayerTimeJamaat"></asp:TextBox>
</tr>
<tr>
<td>
<asp:Label ID="lblSunrise" runat="server" CssClass="prayerLabelscss" Text="Sunrise"></asp:Label>
</td>
<td style="text-align: center">
<asp:Label ID="lblbegSunRiseTime" runat="server" CssClass="prayerTimescss" Text="00:00"></asp:Label>
</td>
<td style="text-align: center">
<asp:Label ID="lbltmrwSunriseTime" runat="server" CssClass="prayerTimeTmrwcss" Text="00:00"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblDkubra" runat="server" CssClass="prayerLabelscss" Text="Dahawa Kubra"></asp:Label>
</td>
<td>
<asp:Label ID="lblDkubraTime" runat="server" CssClass="prayerTimescss" Text="00:00"></asp:Label>
</td>
<td style="text-align: center"></td>
<td id="td1" style="text-align: center"></td>
</tr>
<tr>
<td>
<asp:Label ID="lblDhuhr" runat="server" CssClass="prayerLabelscss" Text="Dhuhr"></asp:Label>
</td>
<td style="text-align: center">
<asp:Label ID="lblbegDhuhrTime" runat="server" CssClass="prayerTimescss" Text="00:00"></asp:Label>
</td>
<td style="text-align: center">
<asp:Label ID="lbltmrwDhuhrTime" runat="server" CssClass="prayerTimeTmrwcss" Text="00:00"></asp:Label>
</td>
<td id="tddhuhrJamaatbox" style="text-align: center">
<asp:TextBox ID="txtDhuhrJamaat" runat="server" CssClass="prayerTimeJamaat" Text="00:00" onmousedown="displayPicker('Dhuhr','tddhuhrJamaatbox');" MaxLength="5"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblAsr" runat="server" CssClass="prayerLabelscss" Text="Asr"></asp:Label>
</td>
<td style="text-align: center">
<asp:Label ID="lblbegAsrTime" runat="server" CssClass="prayerTimescss" Text="00:00"></asp:Label>
</td>
<td style="text-align: center">
<asp:Label ID="lbltmrwAsrTime" runat="server" CssClass="prayerTimeTmrwcss" Text="00:00"></asp:Label>
</td>
<td id="tdasrJamaatbox" style="text-align: center">
<asp:TextBox ID="txtAsrJamaat" runat="server" CssClass="prayerTimeJamaat" Text="00:00" onmousedown="displayPicker('Asr','tdasrJamaatbox');" MaxLength="5"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblMaghrib" runat="server" CssClass="prayerLabelscss" Text="Maghrib"></asp:Label>
</td>
<td style="text-align: center">
<asp:Label ID="lblbegMaghribTime" runat="server" CssClass="prayerTimescss" Text="00:00"></asp:Label>
</td>
<td style="text-align: center">
<asp:Label ID="lbltmrwMaghrib" runat="server" CssClass="prayerTimeTmrwcss" Text="00:00"></asp:Label>
</td>
<td id="tdmaghribJamaatbox" style="text-align: center">
<asp:TextBox ID="txtMaghribJamaat" runat="server" CssClass="prayerTimeJamaat" Text="00:00" onmousedown="displayPicker('Maghrib','tdmaghribJamaatbox');" MaxLength="5"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblIsha" runat="server" CssClass="prayerLabelscss" Text="Isha"></asp:Label>
</td>
<td style="text-align: center">
<asp:Label ID="lblbegIshaTime" runat="server" CssClass="prayerTimescss" Text="00:00"></asp:Label>
</td>
<td style="text-align: center">
<asp:Label ID="lbltmrwIshaTime" runat="server" CssClass="prayerTimeTmrwcss" Text="00:00"></asp:Label>
</td>
<td id="tdishaJamaatbox" style="text-align: center">
<asp:TextBox ID="txtIshaJamaat" runat="server" CssClass="prayerTimeJamaat" Text="00:00" onmousedown="displayPicker('Isha','tdishaJamaatbox');" MaxLength="5"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblJamaat" runat="server" CssClass="prayerLabelscss" Text="Jummah 1"></asp:Label>
</td>
<td></td>
<td></td>
<td id="tdjummah1Jamaatbox" style="text-align: center">
<asp:TextBox ID="txtJummah1Jamaat" runat="server" CssClass="prayerTimeJamaat" Text="13:30" onmousedown="displayPicker('Jummah1','tdjummah1Jamaatbox');" MaxLength="5"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblJummah2" runat="server" CssClass="prayerLabelscss" Text="Jummah 2"></asp:Label>
</td>
<td></td>
<td></td>
<td id="tdjummah2Jamaatbox" style="text-align: center">
<asp:TextBox ID="txtJummah2Jamaat" runat="server" CssClass="prayerTimeJamaat" Text="13:30" onmousedown="displayPicker('Jummah2','tdjummah2Jamaatbox');" MaxLength="5"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="4">
<asp:Button ID="btnRadioStatus" OnClick="btnRadioStatus_Click" runat="server" Enabled="false" CssClass="cssRadioStatus"
Text="Button" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Timer ID="TimerPrayer" runat="server" OnTick="TimerPrayer_Tick" Interval="10000"></asp:Timer>
</div>
code behind
protected void TimerPrayer_Tick(object sender, EventArgs e)
{
ReadMyData();
}
I had the same problem. I put a timer inside my update panel. It was not firing its OnTick event callback at all.
I moved the timer outside the update panel and then it started firing on the callback.
Then I added a Trigger for the timer in the update panel and it works:
<asp:UpdatePanel ID="UpdatePanelChart" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="tmChartPanel"
EventName="Tick" />
</Triggers>
<!-- ... -->
I had this in my page load which was stopping the postback
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "setDOM", "$(\"#divDigitalClock\").clock({ \"langSet\":\"en\",\"format\":\"24\"});", true);
Maybe you can use trigger.Because update panel postback works with trigger.
You don't have to use timer in update panel,use timer outside the update panel.
And as an example using timer in update panel
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
<!-- your content here, no timer -->
</ContentTemplate>
</asp:UpdatePanel>
<asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="Timer1_Tick">
</asp:Timer>
source of code
I have 3 text fields on my page and one calendar control. After I fill in the 3 text boxes, then click a date on the calendar control, the bottom textfield clears out, losing its value. The other 2 text boxes have their values available and do not get cleared. The textboxes all have the same properties, but I can't figure out how to keep the value in the third textbox.
<table class="auto-style2" align="center">
<tr>
<td class="auto-style4" style="text-align: right">Project Name:</td>
<td style="text-align: left">
<asp:TextBox ID="TxtProjectName" runat="server" height="32px" width="211px" MaxLength="50" OnTextChanged="TxtProjectName_TextChanged" onKeyUp="Count(this,50)" onChange="Count(this,50)" TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TxtProjectName" ErrorMessage="Field is required"></asp:RequiredFieldValidator>
</td>
</tr>
</table>
<table class="auto-style2" align="center">
<tr>
<td class="auto-style4" style="text-align: right">Project Description:</td>
<td style="text-align: left">
<asp:TextBox ID="TxtDescription" runat="server" height="45px" width="211px" TextMode="MultiLine" OnTextChanged="TxtDescription_TextChanged"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TxtDescription" ErrorMessage="Field is required"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style4" style="text-align: right">Contact Name:</td>
<td style="text-align: left">
<asp:TextBox ID="TxtContactName" runat="server" Width="203px" OnTextChanged="TxtContactName_TextChanged" Height="16px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="TxtContactName" ErrorMessage="Field is required"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style5">Business Area:</td>
<td class="auto-style3">
<asp:DropDownList ID="DDLBusinessArea" runat="server" style="text-align: left">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="auto-style4" style="text-align: right">Priority:</td>
<td style="text-align: left">
<asp:DropDownList ID="DDLPriority" runat="server">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="auto-style4" style="text-align: right">Desired Completion Date:</td>
<td style="text-align: left">
<asp:Calendar ID="Calendar1" runat="server">
<SelectedDayStyle Font-Bold="True" />
<TodayDayStyle ForeColor="#3333FF" />
</asp:Calendar>
</td>
</tr>
Its the TxtContactName that clears.
i have a search form in which i have certain controls (TextBox,DropDownList,CheckBox etc.) i have a search button in which the code for getting the result set if written.I want search button click event to get fired when i hit enter button,for this is have written
<form id="form1" runat="server" defaultbutton="btnSearch">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
</telerik:RadCodeBlock>
<telerik:RadDatePicker ID="RadDatePicker1" Style="display: none;" MinDate="01/01/1900"
MaxDate="12/31/2100" runat="server">
<ClientEvents OnDateSelected="dateSelected" />
</telerik:RadDatePicker>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="25" align="center" valign="middle">
<table width="96%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="400" align="left" valign="top">
<span style="color: #FFFFFF; font-weight: bold;">
<asp:Label ID="lblName" runat="server"></asp:Label></span>
</td>
<td align="right" style="color: #FFFFFF; font-weight: bold;">
<asp:LinkButton ID="lbtnLogout" runat="server" Text="Logout" ForeColor="#FFFFFF"
Font-Bold="true" OnClick="lbtnLogout_Click">Logout</asp:LinkButton>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="10" align="center" valign="middle">
</td>
</tr>
<tr>
<td align="center" valign="top" bgcolor="#FFFFFF">
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="background: url(../img/bg02.png) #FFFFFF no-repeat top right;">
<tr>
<td align="left" valign="middle">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="250" align="left">
<img src="../img/goDigital_Logo01.png" width="198" height="91">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="3" align="center" valign="middle" style="background: url(../img/bg01.png) no-repeat;">
<asp:Label ID="lblError" runat="server" ForeColor="Red"></asp:Label>
<asp:UpdateProgress ID="UpdateProgress2" runat="server">
<ProgressTemplate>
<table cellpadding="0" cellspacing="0" width="140">
<tr>
<td width="26">
<asp:Image ID="Image3" runat="server" ImageAlign="AbsMiddle" Width="16px" Height=" 16px"
CssClass="PreLoader" ImageUrl="~/Images/preloader-square.gif" />
</td>
<td class="HD1b">
Please wait...
</td>
</tr>
</table>
</ProgressTemplate>
</asp:UpdateProgress>
</td>
</tr>
<tr>
<td align="left" valign="top">
<table width="100%" border="0" cellspacing="2" cellpadding="1" style="background: url(../img/bg-shadow.png) repeat-x center bottom;">
<tr>
<td width="20" class="color2">
</td>
<td width="100" class="color2">
<strong>Vendor Code</strong>
</td>
<td width="5">
<strong>:</strong>
</td>
<td colspan="2">
<table cellpadding="0" cellspacing="0" width="80%">
<tr>
<td>
<strong>
<telerik:RadComboBox ID="radtxtVendorCode" runat="server" EmptyMessage="Select Vendor Code"
EnableLoadOnDemand="true" EnableVirtualScrolling="true" Filter="Contains" HighlightTemplatedItems="true"
Height="180px" Style="margin-left: 0px" Width="100%">
<WebServiceSettings Method="GetVendorCode" Path="AccountSearch.aspx" />
</telerik:RadComboBox>
</strong>
</td>
</tr>
</table>
</td>
<td width="130" class="color2">
<strong>Invoice Date</strong>
</td>
<td width="5">
<strong>:</strong>
</td>
<td>
<strong>
<telerik:RadDatePicker ID="RadDPInvoiceDateFrom" runat="server">
<Calendar ID="Calendar3" runat="server" EnableKeyboardNavigation="true">
</Calendar>
</telerik:RadDatePicker>
</strong>
</td>
<td>
<strong>To</strong>
</td>
<td>
<strong>
<telerik:RadDatePicker ID="RadDPInvoiceDateTo" runat="server">
<Calendar ID="Calendar4" runat="server" EnableKeyboardNavigation="true">
</Calendar>
</telerik:RadDatePicker>
</strong>
</td>
</tr>
<tr>
<td class="color2">
<strong>Vendor Name</strong>
</td>
<td>
<strong>:</strong>
</td>
<td colspan="2">
<table cellpadding="0" cellspacing="0" width="80%">
<tr>
<td>
<strong>
<telerik:RadComboBox ID="radtxtVendorName" runat="server" EmptyMessage="Select Vendor Name"
EnableLoadOnDemand="true" EnableVirtualScrolling="true" Filter="Contains" Height="180px"
HighlightTemplatedItems="true" Style="margin-left: 0px" Width="100%">
<WebServiceSettings Method="GetVendorName" Path="AccountSearch.aspx" />
</telerik:RadComboBox>
</strong>
</td>
</tr>
</table>
</td>
<td class="color4">
<strong>Invoice Amount</strong>
</td>
<td>
<strong>:</strong>
</td>
<td>
<strong>
<telerik:RadNumericTextBox ID="RadtxtInvoicFromAmt" runat="server" Culture="en-IN"
EmptyMessage="From Amount" Width="120px">
<EmptyMessageStyle Font-Italic="True" />
</telerik:RadNumericTextBox>
</strong>
</td>
<td>
<strong>To</strong>
</td>
<td>
<strong>
<telerik:RadNumericTextBox ID="RadtxtInvoicToAmt" runat="server" Culture="en-IN"
EmptyMessage="To Amount" Width="120px">
<EmptyMessageStyle Font-Italic="True" />
</telerik:RadNumericTextBox>
</strong>
</td>
</tr>
<tr>
<td class="color1">
<strong>Print Ref. No</strong>
</td>
<td>
<strong>:</strong>
</td>
<td width="160">
<strong>
<telerik:RadTextBox ID="RadtxtPrintRefNo" runat="server" EmptyMessage="Enter Print Ref No"
Width="160px">
<EmptyMessageStyle Font-Italic="True" />
</telerik:RadTextBox>
</strong>
</td>
<td rowspan="3" align="left" valign="top">
<strong>
<img src="../img/digital1.jpg" width="160" height="119"></strong>
</td>
<td class="color4">
<strong>Transaction Date</strong>
</td>
<td>
<strong>:</strong>
</td>
<td>
<strong>
<telerik:RadDatePicker ID="RadDTTxnFromDate" runat="server">
<Calendar ID="Calendar1" runat="server" EnableKeyboardNavigation="true">
</Calendar>
</telerik:RadDatePicker>
</strong>
</td>
<td>
<strong>To</strong>
</td>
<td>
<strong>
<telerik:RadDatePicker ID="RadDTTxnToDate" runat="server">
<Calendar ID="Calendar2" runat="server" EnableKeyboardNavigation="true">
</Calendar>
</telerik:RadDatePicker>
</strong>
</td>
</tr>
<tr>
<td class="color4">
<strong>Invoice No</strong>
</td>
<td>
<strong>:</strong>
</td>
<td>
<strong>
<telerik:RadTextBox ID="RadtxtInvoicNo" runat="server" EmptyMessage="Enter Invoic No"
Width="160px">
<EmptyMessageStyle Font-Italic="True" />
</telerik:RadTextBox>
</strong>
</td>
<td>
</td>
<td class="color4">
<strong>NEFT / Chq No</strong>
</td>
<td>
<strong>:</strong>
</td>
<td>
<strong>
<telerik:RadTextBox ID="RadtxtneftNoFrom" runat="server" EmptyMessage="Enter From Neft No"
Width="120px">
<EmptyMessageStyle Font-Italic="True" />
</telerik:RadTextBox>
</strong>
</td>
</tr>
<tr>
<td valign="top" class="color4">
<strong>Currency</strong>
</td>
<td valign="top">
<strong>:</strong>
</td>
<td valign="top">
<strong>
<telerik:RadComboBox ID="radtxtCurrencyCode" runat="server" Height="121px" HighlightTemplatedItems="true"
Filter="Contains" EmptyMessage="Select Currency" EnableLoadOnDemand="true" EnableVirtualScrolling="true"
Width="163px">
<WebServiceSettings Method="GetCurrencyCode" Path="AccountSearch.aspx" />
</telerik:RadComboBox>
</strong>
</td>
<td valign="top" class="color4">
<strong>Remarks / Naration</strong>
</td>
<td valign="top">
<strong>:</strong>
</td>
<td colspan="4" valign="top">
<strong>
<asp:TextBox ID="txtRemarks" runat="server" Width="330px" TextMode="MultiLine"></asp:TextBox>
</strong>
</td>
</tr>
<tr>
<td align="left" valign="top">
<asp:ImageButton ID="btnSearch" runat="server" ImageUrl="~/img/btnsearch.png" Width="125"
Height="45" OnClick="btnSearch_Click" OnClientClick="return checkdate();" />
</td>
<td colspan="4" valign="top">
<asp:ImageButton ID="btnClear" runat="server" ImageUrl="~/img/btnclear.png" Width="125" Height="45" OnClick="btnClear_Click" />
</tr>
</table>
</td>
</tr>
<tr>
<td height="120" align="left" valign="top" bgcolor="#C2E8F3">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<telerik:RadGrid ID="rdSearchResult" runat="server" GridLines="None" AllowPaging="True"
SkinID="MySkin" AutoGenerateColumns="false" AllowMultiRowSelection="True" AllowSorting="false"
OnNeedDataSource="rdSearchResult_NeedDataSource" Skin="Windows7">
<PagerStyle AlwaysVisible="True" />
<MasterTableView>
<CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
<Columns>
<telerik:GridTemplateColumn HeaderText="Supp Code">
<ItemTemplate>
<%# Eval("suppcode")%></ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Party">
<ItemTemplate>
<%# Eval("party_name")%></ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Ref No">
<ItemTemplate>
<%# Eval("print_refno")%></ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Currency">
<ItemTemplate>
<%# Eval("currcode")%></ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Invoice No">
<ItemTemplate>
<%# Eval("invno")%></ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Invoice Amt">
<ItemTemplate>
<%# Eval("invAmt")%></ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Invoice Date">
<ItemTemplate>
<asp:Label ID="lblDate" runat="server" Text='<%#Convert.ToDateTime(Eval("invdt")).ToString("dd/MM/yyyy") %>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<PagerStyle AlwaysVisible="True"></PagerStyle>
</MasterTableView>
<ClientSettings ClientEvents-OnRowDblClick="rdSearchResultDblClick" EnableRowHoverStyle="true">
<ClientEvents OnRowDblClick="rdSearchResultDblClick"></ClientEvents>
<Selecting AllowRowSelect="true" />
</ClientSettings>
<SelectedItemStyle BackColor="#C2E8F3" />
</telerik:RadGrid>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td bgcolor="#C44533">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
but this works only when i click somewhere out (take focus off the searching control)and then hit enter
Please suggest
You can place your controls inside a asp:panel and set it's default button.
<asp:Panel ID="p" runat="server" DefaultButton="myButton">
<%-- Text boxes here --%>
<%-- drop down here --%>
.....
<asp:Button ID="myButton" runat="server" />
</asp:Panel>
set a default button to be clicked when the user presses Enter? Simply add the following line to your page's Load event, replacing "btnSearch" with the name of your button. It uses a hidden Page method called RegisterHiddenField and works splendidly:
Page.RegisterHiddenField("__EVENTTARGET", "btnSearch")
Source :-Default Button
try using Button and its UseSubmitBehavior
<asp:Button ID="btnSearch" runat="server" Width="125" Height="45" UseSubmitBehavior="true" />
instead of Image button.
You can easily set the background image of button using css. so don't use Image Button
Place this script below the scriptmanager:
<script type="text/javascript">
var $p = Telerik.Web.UI.RadComboBox.prototype;
var keyDownHandler = $p._onKeyDown;
$p._onKeyDown = function (e) {
var oReturnValue = e.returnValue;
var oPreventDefault = e.preventDefault;
var keyCode = e.keyCode || e.which;
if (keyCode === 13)
e.preventDefault = null;
keyDownHandler.call(this, e);
if (keyCode === 13) {
e.returnValue = oReturnValue;
e.preventDefault = oPreventDefault;
}
};
</script>
I have following design:
Code for it:
<table width="70%" align="center" class ="TableBorder">
<tr>
<td colspan="2" class="Heading" align="center">
Add Client
</td>
</tr>
<tr>
<td class="NormalText" align="right">
Client Name:
</td>
<td align="left">
<asp:TextBox ID="txtClientName" runat="server" CssClass="ThinTextBox"></asp:TextBox>
<asp:Label ID="lblAgentName0" runat="server" ForeColor="#FF3300" Text="*"></asp:Label>
</td>
</tr>
<tr>
<td class="NormalText" width="40%" align="right">
Client Login Email ID:
</td>
<td align="left">
<asp:TextBox ID="txtClientID" runat="server" CssClass="ThinTextBox"></asp:TextBox>
<asp:Label ID="lblAgentName1" runat="server" ForeColor="#FF3300" Text="*"></asp:Label>
</td>
</tr>
<tr>
<td class="NormalText" align="right">
Client Password:
</td>
<td align="left">
<asp:TextBox ID="txtClientPwd" runat="server" CssClass="ThinTextBox"></asp:TextBox>
<asp:Label ID="lblAgentName2" runat="server" ForeColor="#FF3300" Text="*"></asp:Label>
</td>
</tr>
<tr>
<td align="right" class="NormalText">
Contact No.:</td>
<td align="left">
<asp:TextBox ID="txtContactNo" runat="server" CssClass="ThinTextBox"></asp:TextBox>
<asp:Label ID="lblAgentName3" runat="server" ForeColor="#FF3300" Text="*"></asp:Label>
</td>
</tr>
<tr>
<td align="right" class="NormalText" valign="top" >
Address:</td>
<td align="left">
<asp:TextBox ID="txtAddress" runat="server" CssClass="ThinTextBox"
Height="100px" TextMode="MultiLine" Width="200px"></asp:TextBox>
<asp:Label ID="lblAgentName4" runat="server" ForeColor="#FF3300" Text="*"></asp:Label>
</td>
</tr>
<tr>
<td align="right" class="NormalText" width="30%">
</td>
<td align="left">
<asp:Button ID="btnSave" runat="server" CssClass="ButtonColor" Text="Save" />
<asp:Button ID="btnCancel" runat="server" CssClass="ButtonColor"
Text="Cancel" />
</td>
</tr>
</table>
I just wanted to remove spacing between marked area of Address textbox and "*" label.
I tried to give property as valign="top" to label, but its not accepting it.
Please help me.
try this
add style="vertical-align:top;" to label
<asp:Label ID="lblAgentName4" runat="server" ForeColor="#FF3300" Text="*" style="vertical-align:top;"></asp:Label>
Try this one,
<table width="70%" align="center" class="TableBorder">
<tr>
<td colspan="3" class="Heading" align="center">
Add Client
</td>
</tr>
<tr>
<td class="NormalText" align="right">
Client Name:
</td>
<td align="left" colspan="2">
<asp:TextBox ID="txtClientName" runat="server" CssClass="ThinTextBox"></asp:TextBox>
<asp:Label ID="lblAgentName0" runat="server" ForeColor="#FF3300" Text="*"></asp:Label>
</td>
</tr>
<tr>
<td class="NormalText" width="40%" align="right">
Client Login Email ID:
</td>
<td align="left" colspan="2">
<asp:TextBox ID="txtClientID" runat="server" CssClass="ThinTextBox"></asp:TextBox>
<asp:Label ID="lblAgentName1" runat="server" ForeColor="#FF3300" Text="*"></asp:Label>
</td>
</tr>
<tr>
<td class="NormalText" align="right">
Client Password:
</td>
<td align="left" colspan="2">
<asp:TextBox ID="txtClientPwd" runat="server" CssClass="ThinTextBox"></asp:TextBox>
<asp:Label ID="lblAgentName2" runat="server" ForeColor="#FF3300" Text="*"></asp:Label>
</td>
</tr>
<tr>
<td align="right" class="NormalText">
Contact No.:
</td>
<td align="left" colspan="2">
<asp:TextBox ID="txtContactNo" runat="server" CssClass="ThinTextBox"></asp:TextBox>
<asp:Label ID="lblAgentName3" runat="server" ForeColor="#FF3300" Text="*"></asp:Label>
</td>
</tr>
<tr>
<td align="right" class="NormalText" valign="top">
Address:
</td>
<td align="left" class="style1" valign="top">
<asp:TextBox ID="txtAddress" runat="server" CssClass="ThinTextBox" Height="100px"
TextMode="MultiLine" Width="200px"></asp:TextBox>
</td>
<td align="left" valign="top">
<asp:Label ID="lblAgentName4" runat="server" ForeColor="#FF3300" Text="*"></asp:Label>
</td>
</tr>
<tr>
<td align="right" class="NormalText" width="30%">
</td>
<td align="left" colspan="2">
<asp:Button ID="btnSave" runat="server" CssClass="ButtonColor" Text="Save" />
<asp:Button ID="btnCancel" runat="server" CssClass="ButtonColor" Text="Cancel" />
</td>
</tr>
</table>
you must use text vertical-align: text-top; in your css for td like this:
<td align="left" style="vertical-align: text-top;">
<asp:TextBox ID="txtAddress" runat="server" CssClass="ThinTextBox"
Height="100px" TextMode="MultiLine" Width="200px"></asp:TextBox>
<asp:Label ID="lblAgentName4" runat="server" ForeColor="#FF3300" Text="*"></asp:Label>
</td>
Because your asp renders your Label control to html span element, and for spans need text-top style/