How to access to code viewable only in browser's "View source"? - c#

Ok, this is weird. I am working on a GIS web site, and i have the next problem. I need to tweak one of the main functions in the site (because i constantly get an error about one of its lines); the problem is that i can't see that chunk of code in any way! I know where it is, because when i open the page with "View Source" browser's option (Chrome), i see the code i need to change, but that is the only way i can see it! I tried Dreamweaver, Notepad++, Visual Studio 2008 (because it's an .aspx page), still nothing. Here is the preview:
<body>
<form id="form1" runat="server">
<div align="center">
<asp:PlaceHolder ID="phScript" runat="server"></asp:PlaceHolder>
<hr />
<br />
<table style="width: 50%;">
<tr>
<td style="font-family: 'Times New Roman', Times, serif; font-size: large;font-weight: bold;">
<asp:Label ID="lblTitol" runat="server" Text="CÀLCUL ÀREES D'INFLUENCIA AL VOLTAN D'UNA ENTITAT"></asp:Label>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
And this is that portion of code as seen in browser's source:
<body>
<form name="form1" method="post" action="zi.aspx" id="form1">
<div align="center">
<SCRIPT language="javascript" type="text/javascript">parent.frames['map'].Oper='4';parent.frames['map'].MetodeTreball='ILLES';parent.frames['map'].Iter='1';parent.frames['map'].Entitats='CEIP';parent.frames['map'].RadiFix='400';parent.frames['map'].Cobertura='100';parent.frames['map'].ReloadMap(1200);</SCRIPT>
<br />
<br />
<br />
<hr />
<br />
<table style="width: 50%;">
<tr>
<td style="font-family: 'Times New Roman', Times, serif; font-size: large; font-weight: bold;">
<span id="lblTitol">CÀLCUL ÀREES D'INFLUENCIA AL VOLTAN D'UNA ENTITAT</span>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
It is the JavaScript part with parent.frames bla bla part that i have to change, if i can. As i can see, that portion of the code is in aspPlaceHolder, is there any way i can access that part and change it? Sorry for this much code, but i tried to explain the problem as closely as i can.

Remember, the source code you are seeing in the first part is the source code of the ASPX file. This will be parsed by the ASP.Net runtime and the HTML sent to the client. So what you want to do is look at the code that is updating the asp:PlaceHolder called phScript.
If you have access to the source code, this will be in the code behind for the ASPX page - it will have the same name but the extension .cs.
This should tell you where and how the javascript is being constructed, at least.

Search for something like phScript.Controls / phScript.Controls.Add in the code-behind file of that aspx file.

Search the project for the term phScript to see what's populating the phScript PlaceHolder.

In visual stdio 2010 when ever a page is rendered to client it is also shown in Solution explorer at the top. This is same code which is viewable in View source of browser.

Related

How to use table instead of gridview?

I dont know if the my question is good or bad or duplicate but I really want to ask you a favor.
My designer gave me grid design using html tables which looks quite handsome but when I use the same css classes in asp gridview it totally looks different.
Additional Info: In my project I have used Telerik grids. I have tried applying all the css at that too but of no use.
I cant change the designer css because its for all our company.
Now at last I want to use the same table as designer gave me and use it as grid but i really dont know how to fill it from datatable?
1. GridView generates/renders code in which it is difficult to impossible to modify.
2. I would stay away from Telerik as well.
3. Use Bootstrap CSS, you should be very happy with bootstrap css framework as you will get that look above very easily.
With Bootstrap you would use classes like class=table table-striped and you effectively have a nice grid with alternating row colors just like I see in the image that you posted.
With ASP.NET , use Nuget and install Bootstrap. Reference in Masterpage or layout.
I assume that you have styles that overwrite what your designer gave to you. Perhaps also if you are using THEIR stylesheets, make sure to overwrite the default styles. Either OMIT the style reference in master page etc... or place their stylesheet references below the default in say a asp.net web forms or mvc application. ( I assume web forms with masterpage since you are saying Gridview).
You can use ListView to include components. here is the example code for ListView.
<asp:ListView ID="ListView1" GroupPlaceholderID="group" GroupItemCount="1" ItemPlaceholderID="item" runat="server">
<LayoutTemplate>
<table>
<asp:PlaceHolder runat="server" ID="group"></asp:PlaceHolder>
</table>
</LayoutTemplate>
<GroupTemplate>
<tr>
<asp:PlaceHolder runat="server" ID="item"></asp:PlaceHolder>
</tr>
</GroupTemplate>
<ItemTemplate>
<td>
<table cellpadding="2" cellspacing="0" border="1" style="width: 200px; height: 100px">
<tr>
<td>
<span>
<%# Eval("Id") %>
</span>
</td>
</tr>
<tr>
<td>
Name: <span><%# Eval("Field_name_of_your_DB") %></span><br />
Number: <span><%# Eval("Field_name_of_your_DB") %></span><br />
Date: <span><%# Eval("Field_name_of_your_DB", "{0:MM dd, yyyy}") %></span><br />
Comment: <span><%# Eval("Field_name_of_your_DB") %></span><br />
</td>
</tr>
</table>
</td>
</ItemTemplate>
</asp:ListView>

Stop asking for save password [duplicate]

This question already has answers here:
Disable browser 'Save Password' functionality
(35 answers)
Closed 7 years ago.
I'm using ASP.NET 2008 to create an web application with login page "Login.aspx". In that I've use control. Inside that I've created a table structure to place the controls and in that I've place username and password textboxes.
<asp:Login ID="LoginUser" LoginButtonStyle-CssClass="CommonButton" runat="server"
OnLoggedIn="LoginUser_LoggedIn" OnLoginError="LoginUser_Error" TitleText=""
Width="100%" DisplayRememberMe="true" OnLoggingIn="LoginUser_LoggingIn">
<div style="margin-left: auto; margin-right: auto;">
<table border="0" cellpadding="0" style="margin-left: auto; margin-right: auto;">
<tr>
<td style="padding-bottom: 8px;">
<asp:TextBox ID="UserName" runat="server" autocomplete="off" CssClass="CommonTextBox" Width="325" TextMode="SingleLine"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="Password" runat="server" autocomplete="off" CssClass="CommonTextBox" Width="325" TextMode="Password"></asp:TextBox>
</td>
</tr>
</table>
</div>
</asp:Login>
Now when I enter username and password, the browser prompts for save password. But I don't need that prompt.
I'm not using any HTML controls. Its all ASP.NET controls.
How to prevent browser from prompt..?
I've used everything that was already answered. But nothing worked for me. That's why Ive asked newly. I searched for many possible ways, and all failed. This is not a duplicate one.
In your form in the HTML set the attribute autocomplete="off"
<form autocomplete="off" id="form1">

How can I hide an HTML table row <tr> in aspx file and enable in code behind?

I have a very small search functionality and I have a table row called "Search Results", I want this table row get displayed whenever i have something to display from the search results. So I want to hide this row by default and enable via code behind when my search is fetching some result.
<div>
<table>
<tr id="srchResultHeader" style="display: none;" class="header">
<td colspan="2" class="tdlogintitle" visible="false">Search Results</td>
</tr>
<tr>
<td>/*Data to display actual result from database*/</td>
</tr>
</table>
</div>
I'm not able to get the reference of the above table id "srchResultHeader" in my code behind? What is wrong here in my code.
An id by itself is just a client-side identifier. In order for this to be referenced as a server-side object it needs to be a server-side control. The easiest way would just be to add runat="server" on the existing element:
<tr runat="server" id="srchResultHeader" style="display: none;" class="header" >
In this case you probably don't even need the style attribute, since you're controlling the hide/show functionality in server-side code. You can just set .Visible on the control to determine whether or not it renders to the client-side markup at all.
You could use server-side <asp:Table> for this very purpose. Otherwise <tr> is a client-side thing and is not directly accessible in the server-side code. <asp:Table> will render <table> tag on the client-side, but you can access it in the code-behind through its ID. The structure looks like this:
<asp:Table ID="MyTable" runat="server">
<asp:TableRow runat="server" ID="MyRow1">
<asp:TableCell>Some value</asp:TableCell>
</asp:TableRow>
</asp:Table>
You can now write something like this in the code-behind:
MyRow1.Visible = False;
.aspx
<tr id="divDriverName1" runat="server" >
<td >
<label class=" ">label1 </label>
<asp:TextBox ID="TextBox1" runat="server" class=" form-control"></asp:TextBox>
</td>
</tr>
.aspx.cs
ContentPlaceHolder myPlaceHolder = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
HtmlTableRow ct = (myPlaceHolder.FindControl("divDriverName1")) as HtmlTableRow;
divDriverName1.Attributes.Add("style", "display:none");
<div class="row" id="divhiddenInfo2" runat="server" style="display: none">
</div>

html input of type File wrapped inside ASP: Panel is not disabled when panel is disabled

I have wrapped HTML Input control of type File inside ASP:Panel control(which is wrapped inside update panel).
When I disable ASP:Panel control, input control is still enable. Please helpme out
ASPX Code :
<asp:Panel ID="pnlBrowseCSV" runat="server" Enabled="true">
<table>
<tr>
<td align="left" valign="top" style="height: 30px; width: 160px;">
<strong>CSV File:</strong>
</td>
<td style="height: 30px">
<input type="file" id="csvFile" runat="server"
onkeydown="return false" style="width: 350px; background-color:white"/>
<strong>(*.csv)</strong>
</td>
<td style="height: 30px">
<ASP:Button ID="btnValidate" Text="Validate" runat="server"
OnClick="btnValidate_Click" />
</td>
</tr>
</table>
</asp:Panel>
Using visible attribute instead of Enabled.
<asp:Panel ID="pnlBrowseCSV" runat="server" Visible="False">
This issue is by design. What you can do rather is write one extra line of code to disable File upload where you disable the panel.
pnlBrowseCSV.Enabled = false;
csvFile.Enabled=false;

Javascript for a popup. Asp.net for Visual Studio 2005

What JavaScript has to be written for a popup when a link is clicked? Correct me if there is anything else to be done.
Link is written like this.
<div style="float:left; padding-left:9px;">
<asp:LinkButton ID="lnkActiveInactive" runat="server" OnClick="lnkActiveInactive_Click"
CssClass="linkclass" Font-Underline="True">Cancel My Account</asp:LinkButton>
</div>
And popup extender is like this.
<cc1:ConfirmButtonExtender DisplayModalPopupID="ModalPopupExtender2" ID="ConfirmButtonExtender2"
runat="server" TargetControlID="lnkActiveInactive">
</cc1:ConfirmButtonExtender>
<cc1:ModalPopupExtender ID="ModalPopupExtender2" OkControlID="btnYesCancel" CancelControlID="btnNoCancel"
BackgroundCssClass="modalBackground" PopupControlID="pnlCancelPopup" TargetControlID="lnkActiveInactive"
runat="server">
</cc1:ModalPopupExtender>
<asp:Panel CssClass="modalPopup" ID="pnlCancelPopup" runat="server">
<!-- Common Popup Control Begin -->
<table class="tblCommonPopup" width="690px" cellpadding="0" cellspacing="0">
<tr>
<td class="topLeft">
</td>
<td class="topMiddle">
</td>
<td class="topRight">
</td>
</tr>
<tr>
<td colspan="3" class="middle" align="center">
<!-- Content Area Begin -->
<table>
<tr>
<td>
</td>
<td colspan="2" style="padding-top: 10px;">
<table width="100%">
<tr>
<td align="center">
Feel free to change your package to Basic, there is no charge for this Package.<br /><br />If you still wish to cancel,
your account will become inactive within DealTown and any further billing will <br />discontinue.
We will keep you account in our system for some time if you wish to active it again.<br /><br />Are you sure you
wish to cancel your account?
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" colspan="4">
<input id="btnYesCancel" type="button" value="YES" class="popupButton" />
<input id="btnNoCancel" type="button" value="NO" class="popupButton" />
</td>
</tr>
</table>
<!-- Content Area Ends -->
</td>
</tr>
<tr>
<td class="bottomLeft">
</td>
<td class="bottomMiddle">
</td>
<td class="bottomRight">
</td>
</tr>
</table>
<!-- Common Popup Control End -->
</asp:Panel>
Im not sure if I understood your question clearly, but this is how to pop up in JS
<script type="text/javascript">
<!--
function Confirmation() {
var answer = confirm("Are you sure you want to Cancel your Account?")
if (answer){
alert("Goodbye!")
}
else{
alert("Thanks for not Cancelling")
}
}
//-->
</script>
<div style="float:left; padding-left:9px;">
<asp:LinkButton ID="lnkActiveInactive" onclick="Confirmation();">Cancel My Account</asp:LinkButton>
</div>
This code is used is you run on the client side. If you want it to run on server side you have to do it on the codebehind like such
if (!IsPostBack) {
this.lnkActiveInactive.Attributes.Add("onclick", "javascript:Confirmation()");
}
If you just want a confirmation dialog for the 'cancel my account' you can simply place some javascript in your aspx page.
Something like:
onclick="javascript:confirm()"
Hope this helps!
I think the other responders have missed that you are using the ASP.NET Ajax Toolkit ModalPopupExtender.
The answer to your question is, no, no Javascript is required. Setting the TargetControlID of the ModalPopupExtender to your LinkButton should be sufficient to get the pop-up to appear. If that's not happening, something else is wrong.
One thing I notice is that you have an OnClick handler on the LinkButton. This shouldn't be necessary if the only function of the link button is to pop up the dialog.

Categories

Resources