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

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.

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.

Long aspx file gets hard to read - is there a way to simplify

My aspx file has lot's of components and has become difficult to work with when eg. adding new items because I can't see the start and end tags of where the new control must go (especially when adding containers).
I was wondering if there is a way to arrange the code with some kind of placeholder (all within the same file is fine) - something along the lines of the mockup below?
<abc:container>
<abc:pages>
<abc:page>
[Page1CodeGoesHere]
</abc:page>
<abc:page>
[Page2CodeGoesHere]
</abc:page>
</abc:pages>
</abc:container>
<Page1CodeGoesHere>
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</table>
</Page1CodeGoesHere>
<Page2CodeGoesHere>
<table>
<tr>
<td>a</td>
<td>b</td>
<td>c</td>
</tr>
</table>
</Page2CodeGoesHere>
Use ASP.NET User Controls. It allow you to use code from separate files.
It seems you are looking for code-folding a-la #region support.
If yes, then Visual Studio 2013 Update 4 added support for #regions in HTML editor. You would use it like this:
<!-- #region Page1Code -->
..
<!-- #endregion -->
This will allow you to collapse-expand the regions as convenient to you.
Ref: http://blogs.msdn.com/b/webdev/archive/2014/10/16/announcing-new-web-features-in-visual-studio-2013-update-4-rc.aspx
Note 1:
This was voted against for in VS 2015, but was declined. So, #region support for HTML editor is here to stay it seems. Ref: https://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/6571662-do-not-introduce-the-curse-of-regions-to-html
Note 2:
Nothing beats modular approach. Keep your pages small, clean and simple.

Removing a 'New Line' in ASP

How do i remove a new line from the start of a string?
what's happening is that i've been controlling and debugging someone else's php code, and converting it into asp. what he did was put html tags in a db table, and simply echoing them. ex, a field contains html table tags like <thead>,<tbody>,<tr>, etc. i didn't want to continue the wrong doing so what i did was to control them by first turning <tr>s into <br />s, and removing everything else. but problem is that the first <tr> makes a new line in the very start of the string. i want to remove it. another problem is that not all fields has htmlt tags inside, so i have to put something like if text.substring(0,1)="(idk what to put here)" then (maybe the replace or trim functions here). any help please?
here's a sample field content. pretty nasty indeed:
<table width="705" height="323" id="gradient-style" summary="Meeting Results">
<thead>
<tr>
<td width="238">Product</td>
<td width="610">TS2360 Tape<br />
Drive Express</td>
</tr>
</thead>
<tbody>
<tr>
<td>Machine/model, HVEC</td>
<td>3580<br />
S63, 3580S6X</td>
</tr>
<tr>
<td>Product strengths</td>
<td>Multi O/S<br />
Encryption & media<br />
partition capable<br />
LTFS support</td>
</tr>
</tbody>
</table>
so after making <tr>s into <br>s and removing other html tags, output beacame:
Product TS2360 Tape Drive Express
Give background color to the table cells to achieve seamless transition
Machine/model, HVEC 3580 S63, 3580S6X
Product strengths Multi O/S Encryption & media partition capable LTFS support
(supposedly skipping a line before "Product" because it has <tr> before it, but didn't show in the block quote)
Thanks in advance.
var cleanedFieldValue = someValueWithLineBreaks.TrimStart( '\n' );
The VB.NET version might look like:
Dim cleanedFieldValue = someValueWithLineBreaks.TrimStart(ControlChars.Lf)
Edit
It sounds as if you are trying to parse some Html and then do work on it. I would recommend using the Html Agility Pack for that and read about the evils of attempting to use RegEx to parse your Html.

How to parse html table using xml?

I'm having an html table of the format
<table>
<th>
<td> td1 </td>
<td> td2 </td>
<td> td3 </td>
<td> td4 </td>
<td> td5 </td>
<td> td6 </td>
<td> td7 </td>
<td> td8 </td>
<td> td9 </td>
<td> td10 <td>
</th>
</table>
I need to parse through the cells in each row within the table body. I looped through the row using a javascript and inorder to save the html content i'm using webmethod( because on saving, my page will reload and i will lose my html table, to avoid that i stored it on a session using webmethod and this too happens within my javascript call) . The issue is my client side script is getting skipped at times and i'm not able to save my html content. So i thought of to send the html content as a whole in one script call and do the parsing in server-side.
Now, i need to know how to parse it from server-side. Can some-body help me to parse it using xml?
I think you should try HTML Agility Pack
from CodePlex
What is exactly the Html Agility Pack (HAP)?
This is an agile HTML parser that builds a read/write DOM and supports
plain XPATH or XSLT (you actually don't HAVE to understand XPATH nor
XSLT to use it, don't worry...). It is a .NET code library that allows
you to parse "out of the web" HTML files. The parser is very tolerant
with "real world" malformed HTML. The object model is very similar to
what proposes System.Xml, but for HTML documents (or streams).

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?

Resources