Visual Web Developer 2010 suddenly making tables - asp.net

I have a navigation menu defined in visual web developer 2010 express using a bunch of tags. This worked as expected until a few days ago, when I must have accidentally changed something. I noticed the styles were no longer getting displayed on the menu, so I examined my master page and compared it to a default master page.
My page generates this for a menu item:
<table id="ctl00_NavigationMenu" class="menu ctl00_NavigationMenu_2" cellpadding="0" cellspacing="0" border="0">
<tr>
<td onmouseover="Menu_HoverStatic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(event)" id="ctl00_NavigationMenun0"><table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td style="white-space:nowrap;"><a class="ctl00_NavigationMenu_1" href="Default.aspx">Home</a></td>
</tr>
</table></td>
</tr>
</table>
Whereas the default master page generates this:
<li><a class="level1" href="Default.aspx">Home</a></li><li><a class="level1" href="About.aspx">About</a></li>
The problem seems to be that a table is being generated from the MenuItem tag instead of a list. How did I do this and how do I fix it?

Just shot in the dark, but did you make any changes to your framework version? When upgrading a project to 4.0, the following line gets added to your web.config which changes the way some tags are rendered:
<pages controlRenderingCompatibilityVersion="3.5" ...
If it's there, you might try removing it...

Related

Web API to pass values to the web page

I have an web page to which I dont have access to the source code. I will need to create an API that will pass auto generated values to the Text box on the page. As I dont have access to the source code of the page, not sure how I will be able to pass the auto generated values through the API.
When I right click I get the source of the field like below
<div class="OneColTable">
<table class="DataInputTable">
<tr>
<td colspan="2"><h3>Enter Project Information</h3><br/></td>
</tr>
<tr>
<tr>
<td class="label">Project name:</td>
<td><input type="text" name="project.name" value="" class="RequiredField"></td>
</tr>
</tr>
I have create an WEb API before but not sure how to approach this scenario. Any help is greatly appreciated.

Better way of showing images from a model in razor

EDIT: it was the #ViewBag.Persona(item.IDPersona) part the problem.
In a view I iterate over a collection of models, each model has an url that corresponds to an image in the server. I want to display in a table every model with its image. So I did something like this:
<table class="tbody">
<tr class="th">
<th>ID
</th>
<th>Person
</th>
<th>Image
</th>
</tr>
#foreach (var item in Model.Entity)
{
<tr>
<td>
#Html.ActionLink(item.IDPersona.ToString(), "Edit", "Persona", new{Id = item.IDPersona}, null)
</td>
<td>
#ViewBag.Persona(item.IDPersona)
</td>
<td>
<img src="/img/#item.ImageName" height="100" width="100" />
</td>
</tr>
}
</table>
But the page can take up to 13 seconds to load. I imagine that the reason is because I am loading one image at a time instead of loading multiple images simultaneously.
Is there a way to improve the loading time? Maybe "delaying" the load of the image until the model have been iterated entirely, is this possible?
Looking at your code, and going off of the details in your comments, I don't think it's the images causing the issue. If it's simply pulling the images off of the local file system it's not likely that they'd be the cause of the slowness.

ASP:PlaceHolder - can't find code that's generating its contents

I need to update a bit of text that's being rendered on a .aspx page. I've searched the source and DB tables, views, and stored procedures, and can't find it.
The bit of code that's generating the text looks like this:
<asp:PlaceHolder id="teamMemberTable" runat="server" />
I searched and couldn't find any references to teamMemberTable anywhere else in the code. Is it possible that the code generating that bit has been compiled into binary and doesn't exist in plaintext anymore?
Here is an example of the outputted html:
<span id="ctl00_rightContent_Repeater1_ctl01_Literal1" class="teamListName">
Team Number One
</span>
<table>
<tr>
<td class="teamListMember">Team Captian</td>
<td class="teamListPlayer">Jane Doe</td>
<td class="teamListStatus teamListStatusPaid">Paid</td>
</tr>
<tr>
<td class="teamListMember">Player 2</td>
<td class="teamListPlayer">John Q. Public</td>
<td class="teamListStatus teamListStatusNotPaid">Not Paid</td>
</tr>
</table>
Yes, it is possible that the code is in an assembly that has already been compiled and is not in plaintext. One option is to run a tool such as .NET Reflector or ILSpy and decompiling all the assemblies in the app and searching through the decompiled code to locate any references to "teamMemberTable".
Another possibility is that the control is being referenced by index instead of by name. For example, if the PlaceHolder control is in the page, it could be referenced as Page.Controls[5] and so you'd never see the name in the source code.

Why server controls are underlined when placed inside Content tags?

I have a Web Content Form containing a Div and various Server controls like DropDownList. When I run the application, it runs well without any errors, but when I view the HTML source, the Server controls are red underlined. On bringing the mouse over, say, DropDownList, a tooltip warning is displayed:
DropDownList is not a known element. This can occur if there is a compilation error in a website.
Edited
<%# Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="contentReportSchemesMenu.aspx.cs" Inherits="contentReportMenu" Title="Reports Menu" %>
<asp:Content ID="ContentReportMenu" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div id="divMenu" class="divMenu" runat="server">
<table id="tblMenuLayout" class="Options" runat="server">
<tr>
<td colspan="2" class="Top">Scheme Reports Menu</td>
<td></td>
</tr>
<tr>
<td class="Left">Report Type</td>
<td class="Right">
<asp:DropDownList ID="ddlReportType" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlReportType_SelectedIndexChanged"></asp:DropDownList>
</td>
</tr>
<tr>
<td class="Left">Select District</td>
<td class="Right">
<asp:DropDownList ID="ddlDistrict" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlDistrict_SelectedIndexChanged" Enabled="False"></asp:DropDownList>
</td>
</tr>
<tr>
<td class="Left">Select Block</td>
<td class="Right">
<asp:DropDownList ID="ddlBlock" runat="server" AutoPostBack="true" Enabled="False" OnSelectedIndexChanged="ddlBlock_SelectedIndexChanged"></asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="2" style="text-align:center">
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" Enabled="False" />
</td>
<td></td>
</tr>
</table>
</div>
</asp:Content>
A quick Google search soon found the solution: Delete the files from “C:\Documents and Settings[Username]\Application Data\Microsoft\VisualStudio\9.0\ReflectedSchemas” folder (or “…\VisualStudio\8.0\…” if running Visual Studio 2005) in Windows XP. In Windows 7 it is under "C:\Users{User Profile}\AppData\Roaming\Microsoft...etc". Remember also the "VisualStudio" part of the path will be different depending on the version installed.
I closed Visual Studio (always a good ideas for changes that will affect the IDE), deleted the files then re-opened the project. The warnings were gone.
I found references to this solution at:
http://forums.asp.net/t/1205528.aspx
http://blogs.msdn.com/mikhailarkhipov/archive/2005/04/21/410557.aspx
FYI, the search term I used in Google was “element is not supported”.
I don't know why this happens but I do know there are some flakey domain profile things happening in the network environmnet.
You're receiving this error because the table is running at the server, but the tr and td elements are not. When you specify runat="server" on a table element, it expects child elements to run at the server as well.
There are two easy ways to verify this:
Remove runat="server" from the table declaration;
Take the DropDownList(s) outside of the table
Try one of these two options, and see if it fixes the problem.
EDIT
Make sure that the ContentPlaceHolderID on the content form matches the ID of the corresponding content area in the master page. If that doesn't fix your problem, try creating a new content form, applying the advice above, and add a control to the form in the content area. If there are no errors, then you know the issue is somewhere in your markup.
Try deleting the schema cache. To do this, close Visual Studio and delete all of the files in the following directory:
C:\Users\USERNAME\AppData\Roaming\Microsoft\VisualStudio\10.0\ReflectedSchemas
Once the files have been deleted, open Visual Studio again and the problem should be fixed.
You said that "when I view the HTML source, the Server controls are red underlined", but HTML source can not contains such elements like DropDownList because this is the ASP.NET control which is generated as HTML Select tag. Considering that common solution with schema cleanup is not helped you perhaps a problem is in an other place... I'll try to assume that you are opening ASPX/ASCX file itself using some third party editor which is not aware of ASP.NET controls, am I right?

Ajax upatepanel on user control, parent's inline style not rendered by IE

I have a asp.net page, the main content section displays the custom html content from the database. To the right of it, it has a few user control that lets the user make drop down selections and go to its perspective links.
So it's something like this:
<asp:Content ID="Content3" ContentPlaceHolderID="mainContentPlaceHolder" Runat="Server">
<atlas:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server" />
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td valign="top">
<%=Session["xyz"].ToString()%>
</td>
</tr>
</table>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="rightContentPlaceHolder" Runat="Server">
<table cellpadding="0" cellspacing="0" border="0" style="margin-left: 4px;">
<tr>
<td style="width: 239px;">
<uc18:x ID="x1" runat="server" referer="Home" />
<uc17:y ID="y1" runat="server" />
<uc4:z ID="z1" runat="server" />
</td>
</tr>
</table>
</asp:Content>
The user contorls are pretty straight forward. Each one of them has drop downs. If one selects, it populates the next one..etc, and they are wrapped around a update panel so the page won't referesh itself on selection.
The issue i have is when the page first loaded, the content in <%=Session["xyz"].ToString()%>, which sometimes have css inline style, loads fine. However as soon as the user clicks on the first drop down of any user control, the css inline style disappears.
My question is why is the inline style not being rendered by the browser again on ajax postback (only happening in IE, firefox is ok)? What should i do about this?
Thanks in advance.
Angela.
It turns out that there's bug with Atlas. If i use the asp.net ajax, it works fine. Unfortunately i cannot change Atals ajas to asp.net for the time being. My easiest solution was to let the full post back happen.

Resources