|
I hope this is not difficult question. Can someone please answer me.
|
|
|
|
|
Please be patient, it is the weekend in most of the world, and still night in much of the west. People will answer in their own time.
|
|
|
|
|
I'm editing html since notepad with all the versions of VS (2003-2013), and never had problems like one you described here...
You may turn on/off automatic formatting. You may also turn on/off wrapping.
In general - try to play around with HTML editor settings in VS to see what fits you better...
Good luck with the 'become a coder' think anyway...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
I don't have that problem,
check your option settings under editors, and see if line wrapping is checked, and any sort of auto formatting is turned off.
I started out using Dreamweaver back in 2003, but now I just use Visual Studio for everything. I don't use the preview very much, I just run F5, and I keep refreshing the page to check how it looks, so I run the VS on the left monitor, and run 2 or 3 browsers on the right monitor and check each browser.
Don't use the asp.net objects unless you have to. Just write plain HTML in your favorite flavor. Most of the asp.net objects are useless in my opinion. Take the validator object, doesn't work half the time in a production environment.
If your making a form, you can use the Label, and textbox objects.
My rule is, unless I need them in code behind, I just use HTML Objects.
If I'm writing HTML in pure code behind, I use the asp.net HTML Objects.
|
|
|
|
|
I have a big issue with the asp.net site I did. It's hosted on a server station, with IIS 7, and many clients (around 10) are accessing it. Around twice a week, the site is unacessible. When checking on the server, the CPU is at 100%. Resetting he application pool solves it.
The page has a auto-refresh function to update the products status (with color depending on the status). It fetches informations from other internal sites and Perforce. The refresh is done by a timer and set to 30 seconds.
<pre lang="HTML"><pre><asp:Timer ID="tmrTimer" OnTick="tmrTimer_Tick" Interval="300000" runat="server"></asp:Timer>
When the client select a product, I fill the page with the corresponding information. There is a table with the option runat="server" that I clear and fill with lines containing the information.
I place logs to check what was taking so long, but the total init time of the page is always under 1 second (there is information caching), even if the user has to wait more time than that to see the information.
At first, I thought the refresh was taking too long and that it was launching a new refresh before finishing the first one, so I increased the refresh time to 30 seconds, but it does not seem to be the case (unless the user clicks on another product before the product information finished displaying.
Here is my page initialization logic. It might not be the best way (since I don't have much experience with web programming), but it works. I only need to fix the CPU usage issue that forces us to reboot the server once in a while.
I think it might be caused by some threads working that were not terminated for some reason. I have to make a series of tests next week, but wanted to know in which direction to look or if someone had an idea.
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
return;
}
var d = DateTime.Now;
UpdateMenus();
Log.Info("Update menus : " + DateTime.Now.Subtract(d).Milliseconds + " ms");
}
protected void Page_Init(object sender, EventArgs e)
{
var source = "";
var t = DateTime.Now;
var d = DateTime.Now;
SessionSettings.SelectedProductId = Request.QueryString["ProductId"];
if (!IsPostBack)
{
CreateMenusDictionnary();
SessionSettings.TurnAllDisplayOff();
Session[CURRENT_BRANCH_KEY] = null;
Session[CURRENT_SOFTWARE_KEY] = null;
DisplaySelectedProductInfo();
source = "(startup)";
if (!string.IsNullOrEmpty(SessionSettings.SelectedProductId))
{
source = "(" + SessionSettings.SelectedProductId+ ")";
}
}
if (Session["updateProducts"] != null && (bool)Session["updateProducts"])
{
d = DateTime.Now;
UpdateProducts();
Log.Info("Update products status : " + DateTime.Now.Subtract(d).Milliseconds + " ms");
}
var ctrl = WebApplicationHelper.GetPostBackControl(this);
if (!(ctrl is Timer))
{
tmrTimer.Enabled = false;
}
if(ctrl != null)
{
CreateMenusDictionnary();
if (ctrl is Button)
{
var p = FindProduct(SessionSettings.SelectedProductId);
if (Session[SessionSettings.TABLE_MANAGER_KEY] == null)
{
Session[SessionSettings.TABLE_MANAGER_KEY] = new ProductsInfoTableManager(productInfoTable);
}
var manager = (ProductsInfoTableManager)Session[SessionSettings.TABLE_MANAGER_KEY];
manager.SetProductsInfoTable(productInfoTable);
source = "(Expand button)";
switch (ctrl.ID)
{
case "diffButton":
SessionSettings.ShowDifferences = !SessionSettings.ShowDifferences;
manager.RefreshDiffFixes(p);
break;
case "fixesButton":
SessionSettings.ShowFixes = !SessionSettings.ShowFixes;
manager.RefreshDiffFixes(p);
break;
case "manualTestsDisplayChangelistsButton":
source = "(manualTestsDisplayChange)";
SessionSettings.ShowManualTestsByType = ExcelTestsReader.AggregateType.Changelist;
SessionSettings.TurnOffTestsDisplay();
manager.RefreshManualTests(p);
break;
case "manualTestsDisplayTestNamesButton":
source = "(manualTestsDisplayChange)";
SessionSettings.ShowManualTestsByType = ExcelTestsReader.AggregateType.Test;
SessionSettings.TurnOffTestsDisplay();
manager.RefreshManualTests(p);
break;
default:
if (ctrl.ID.StartsWith("errors_"))
{
SessionSettings.ToggleShowErrors(ctrl.ID);
manager.RefreshWorkflowErrors(p);
}
else if (ctrl.ID.StartsWith("manualTestsExpand_"))
{
SessionSettings.ToggleShowManualTest(ctrl.ID);
manager.RefreshManualTests(p);
}
else
{
DisplaySelectedProductInfo();
}
break;
}
}
if (ctrl is Timer)
{
source = "(timer)";
d = DateTime.Now;
UpdateProducts();
Log.Info("Update products status (timer) :" + DateTime.Now.Subtract(d).Milliseconds + " ms");
DisplaySelectedProductInfo();
}
}
Log.Info("Total init time " + source + " : " + DateTime.Now.Subtract(t).Milliseconds + " ms");
if (!tmrTimer.Enabled)
{
tmrTimer.Enabled = true;
}
}
protected void tmrTimer_Tick(object sender, EventArgs e)
{
}
|
|
|
|
|
I've seen that happen before years ago.
Web apps just run on 1 thread, unless you create a new thread as like a background worker process, like sending an email.
I think back in the day, I tries using the timer.
In my opinion, the timer is for windows applications, and not for web apps, so the timer your using is running on the server side, and not the client side.
You really want to shift timers to the client side, let the browser do that work for you.
Page.refresh set to about 30 seconds will handle that for you in HTML via the browser.
http://www.w3schools.com/tags/att_meta_http_equiv.asp[^]
|
|
|
|
|
Ok, I'll try replacing the timer by that refresh option. I have other things running server side (runat="server"), like my products table, to which I add lines depending on the product selected by the user. If I have many users selecting different products, can it have a conflict? (I did not notice any, but just to make sure)
|
|
|
|
|
I was out the door yesterday when looking at your code.
I'm totally off track here on this one.
I had to do some research, and that timer must be the Ajax extension, which runs on the client side, so that is ruled out. I had no idea they had a ajax timer object, I just use the refresh meta tag.
The page.Init and page.load use is correct. I would of done it that way.
I suspect that the issue is in the DisplaySelectedProductInfo(); or UpdateProducts
The code for that might not be very efficient, or something is not being closed or disposed of.
Try remarking out those function 1 at a time to narrow it down.
I would still just dump the timer and use the meta tag refresh.
|
|
|
|
|
Below is my aspx
<%@ Page Title="Report" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Report.aspx.cs" Inherits="Code" EnableEventValidation="false" %>
<asp:content id="Content1" contentplaceholderid="head" runat="Server">
<asp:label id="Label1" runat="server" font-bold="True" font-size="Medium" font-underline="True"
="" forecolor="#000066" text="Reports">
<asp:gridview id="GridView1" runat="server" showfooter="true" onrowdatabound="GridView1_RowDataBound"
="" width="985px" allowsorting="false" gridlines="None">
<footerstyle horizontalalign="Left" verticalalign="Middle">
<headerstyle font-bold="True" font-names="Times New Roman" font-size="Medium" font-underline="True"
="" forecolor="Blue">
<pagerstyle horizontalalign="Left" verticalalign="Top">
<rowstyle horizontalalign="Left" verticalalign="Middle">
<asp:gridview id="GridView2" runat="server" showfooter="true" allowsorting="false"
="" onrowdatabound="GridView1_RowDataBound" width="985px" gridlines="None" style="margin-left: -315px">
<footerstyle horizontalalign="Left" verticalalign="Middle">
<headerstyle font-bold="True" font-names="Times New Roman" font-size="Medium" font-underline="True"
="" forecolor="Blue">
<pagerstyle horizontalalign="Left" verticalalign="Middle">
<rowstyle horizontalalign="Left" verticalalign="Middle">
I am using the below code to export two gridviews to excel.
protected void ExporttoExcel(object sender, EventArgs e)
{
try
{
GridView[] gvList = null;
gvList = new GridView[] { GridView1, GridView2 };
ExportAv("Report.xls", gvList);
}
catch (Exception ex)
{
}
}
public static void ExportAv(string fileName, GridView[] gvs)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fileName));
HttpContext.Current.Response.ContentType = "application/ms-excel";
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
foreach (GridView gv in gvs)
{
gv.AllowPaging = false;
// Create a form to contain the grid
Table table = new Table();
table.GridLines = gv.GridLines;
// add the header row to the table
if (!(gv.Caption == null))
{
TableCell cell = new TableCell();
cell.Text = gv.Caption;
cell.ColumnSpan = 10;
TableRow tr = new TableRow();
tr.Controls.Add(cell);
table.Rows.Add(tr);
}
if (!(gv.HeaderRow == null))
{
table.Rows.Add(gv.HeaderRow);
}
// add each of the data rows to the table
foreach (GridViewRow row in gv.Rows)
{
table.Rows.Add(row);
}
// add the footer row to the table
if (!(gv.FooterRow == null))
{
table.Rows.Add(gv.FooterRow);
}
// render the table into the htmlwriter
table.RenderControl(htw);
}
// render the htmlwriter into the response
string headerTable = @"Report | " + DateTime.Now.ToString("d") + " | ";
HttpContext.Current.Response.Write(headerTable);
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.End();
}
}
This code gives a general title called Report and date at the top of the report. Now how can I possibly give a title name for gridviews when exporting the grid to excel?
|
|
|
|
|
I want to Customize WebApi2 Oauth security provider. I want to use my own data base and own DbContext. Please help me how to do?
I am using asp.net 2013.
Thanks
|
|
|
|
|
How do i add a blog on my ASP.NET webpage
|
|
|
|
|
|
Does this download give step-by-step instructions on how to add the codes to a website.
|
|
|
|
|
|
could u till me a free gateway for sending sms from different free sms providers please could any body tell me
|
|
|
|
|
DO NOT repost.
You have already asking this exact question four times in this forum, and received several helpful answers, none of which you have replied to.
Reposting the same question over and over again will only serve to annoy the people who would otherwise be trying to help you.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
hi MVC4 Razor <a href="/Members/model">@model</a> - what's equivalent in ASPX view engine?
Here's how it's done with Razor - how to do the same in ASPX?
<a href="/Members/model">@model</a> IEnumerable<XYZ.Product>
@{
ViewBag.Title = "Downloads";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div>
<table>
<tr>
<th>Name</th>
<th>Description</th>
<th></th>
</tr>
<a href="/Members/foreach">@foreach</a> (var Package in Model) {
<tr>
<td>
<a href="/Members/html">@Html</a>.DisplayFor(modelItem => Package.Name)
</td>
<td>
<a href="/Members/html">@Html</a>.DisplayFor(modelItem => Package.Description)
</td>
<td>
<a href="/Members/html">@Html</a>.ActionLink("Download", "ProductDownload", Package)
</td>
</tr>
}
</table>
|
|
|
|
|
|
Thankyou Thatraja!
Question, with ASPX you declare your "Model" as such:
<% Inherits="IList<xyz.Product>" %>
Do you still use "Model" keyword when enumerating items from server side script, from "foreach"?
<ul>
<%foreach (var Product in Model)
{ %>
<li><%=Product.Price%></li>
<%} %>
</ul>
|
|
|
|
|
Sorry to disappoint you, I don't use ASPX view as I'm happy with Razor & don't like ASPX view. What happened when you tried that? Always include error message in your message.
Again I'm telling you, go with Razor. It has many advantages, see my previous message.
thatrajaCode converters | Education Needed
No thanks, I am all stocked up. - Luc Pattyn
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is - Henry Minute
|
|
|
|
|
no worries Thatraja, thanks for your help!
|
|
|
|
|
i have Person table and i want access PersonId in complain table.
DataTable dt = PersonBLL.Select(new Person() { ??????? });
I create select code in BLL.
But what write in place of ????? I don't know.
plz help me...
|
|
|
|
|
Dear All,
I have scenario to encrypt the Password in client side and decrypt it in server side (C# code), this is required for a Online website.
Can any one help me on this task.
- Febin R
-
|
|
|
|
|
For using and saving passwords, you really should not be using encryption, you should really hash your passwords using a salt to be saved in the database. Here[^] is an excellent article that goes through password hashing, and goes into some depth.
Hope it helps
Everyone dies - but not everyone lives
|
|
|
|
|
Just use SSL[^]; that way, the whole request and response will be encrypted for you.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|