Unable to debug website project [duplicate] - asp.net

I'm very new to Umbraco, I am still picking my way through how it works so it is entirely possible that I have missed something extremely obvious.
I have been asked to amend how a slider on a MasterPage functions, I've found the markup for the slider is in the .cs file for the MasterPage.
void CreateSlider()
{
if (!String.IsNullOrEmpty(CurrentContent.Slider1Image))
{
slider.InnerHtml += "<li class='foobar'>";
if (!String.IsNullOrEmpty(CurrentContent.Slider1Title))
{
slider.InnerHtml += "<img src='" + GetMedia(CurrentContent.Slider1Image) + "' alt='' />";
slider.InnerHtml += "<div class='slider_content bx-pager-item'>";
slider.InnerHtml += "<h1>" + CurrentContent.Slider1Title + "</h1>";
if (!String.IsNullOrEmpty(CurrentContent.Slider1VideoButtonTitle) && !String.IsNullOrEmpty(CurrentContent.Slider1VideoLink))
slider.InnerHtml += "<span>" + CurrentContent.Slider1VideoButtonTitle + "</span>";
slider.InnerHtml += "</div>";
if (!String.IsNullOrEmpty(CurrentContent.Slider1VideoButtonTitle) && !String.IsNullOrEmpty(CurrentContent.Slider1VideoLink))
{
slider.InnerHtml += "<div class='video_wrapper'>";
slider.InnerHtml += "<div class='youtube_container'>";
slider.InnerHtml += "<div><iframe src='https://player.vimeo.com/video/" + CurrentContent.Slider1VideoLink + "' width='100%' height='542' frameborder='0' webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>";
slider.InnerHtml += "</div>";
slider.InnerHtml += "</div>";
}
}
slider.InnerHtml += "</li>";
}
}
I have tried adding a class to the <li> but it doesn't not show up in the HTML markup at all. I have tried building the project but with no joy.
Here is the markup that is output:
<%# Master Language="C#" MasterPageFile="~/masterpages/Base.master" AutoEventWireup="true" Inherits="HomePageType1" Codebehind="HomePageType1.master.cs" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<div class="slider_container">
<ul id="ContentPlaceHolderDefault_ContentPlaceHolder1_slider" class="bxslider">
<li>
<img src='/media/img001.jpg' alt='' />
<div class='slider_content'>
<!-- SLIDE CONTENT -->
</div>
<div class='video_wrapper'>
<div class='youtube_container'>
<div>
<!-- VIDEO URL -->
</div>
</div>
</div>
</li>
</ul>
</div>
</asp:Content>
Any suggestions?

Any code added to a .cs file outside of /App_Code/ must be compiled before it "counts" - that part should be dealt with when you build the project.
Also, the master page must reference its code behind for it to pick it up, like
<%# Master Language="C#"
AutoEventWireup="true" CodeBehind="MyMasterpage.master.cs" Inherits="MyNamespace.MyMasterpage" %>
Can you perhaps also share the master page content?

The reason this was not functioning correctly is because the previous developers had compiled their code but had also uploaded the C# files to the server. So the files we received were compiled.
After much political wrangling we got them to send us the uncompiled files which allowed me to make the code changes as expected.

Related

ASP include file into variable

I have a template.aspx file the contains code like this:
<html>
....
<body>
<div id="wrapper">
<div id="container">
----sideMenu---
.........
<div id="body">
<%=pageContent%>
</div>
</div>
</body>
</html>
I have a file index.aspx
with the code:
<%
Dim pageContent = ""
%>
<!--#include virtual="template.aspx"-->
I want to insert in pageContent a lot of html code and asp code
without connecting strings like this:
pageContent = "<div class..." &_
" bla bla bla " & aspVariable &_
"more divs and html and asp variables"
.
.
.
actually i want a dyanmic pages i dont want write the template html codes each pages i want that only the pageContent are change.
It would be more common to create a handful of template files to be included in each page of your ASP app. Such as:
header.inc (might contain site, banner... top of page stuff)
topNav.inc (might contain code to generate the top navigation bar)
leftNav.inc (take a guess ;))
bottomCopy.inc (might have text links as site map and copyright statement.
Then, in each page, include all where they should live. For example, in my page called "theFirst.aspx", I might have:
<!-- #include file = "cacheprevent.inc" -->
<!-- #include file = "accesscheck.inc" -->
<!-- #include file = "header.inc" -->
<!-- #include file = "topNav.inc" -->
<!-- #include file = "leftNav.inc" -->
<%
' Here goes the rest of your code to generate content for this specific page
%>
<!-- #include file = "bottomCopy.inc" -->
All this assumes it is in ASP-Classic, as you've tagged your post, at least in part.
... and you could in some cases, combine the top four... if all pages would have the same layout regions.

Response.write doesn't display the image

Writing html using Response.Write in asp.net it doesn't display the image. I check my image path code and simple put it in the page and it works fine. Why it doesn't display the image when writing using response.write code.
Following is my image path code
<img alt="" src="<%= VirtualPathUtility.ToAbsolute("~/Content/images/txt2.png")%>" border="0"/>
This is Response.write code
<% Response.Write(valueHelp); %>
ValueHelp is a string which contain the image code which i have mention above.
Any idea why it is not working?
Thanks in advance
<%= %> is to be used within the mark-up (i.e. the HTML part of your code) and not in the code-behind.
My guess (without seeing the code) is that you are actually sending <%= VirtualPathUtility.ToAbsolute("~/Content/images/txt2.png")%> to the browser as part of a static string.
So instead of it being picked up by the server and rendered into the correct path, it is simply being sent as part of the HTML to the browser (the browser not knowing what on earth it means, therefore it will not show the image you expect).
Try something like this when you are creating the valueHelp string
valueHelp = "<img alt='' src='" + VirtualPathUtility.ToAbsolute("~/Content/images/txt2.png") + "' border='0'/>";
Try this
<% Response.Write("<img alt='' src='" +
VirtualPathUtility.ToAbsolute("~/Content/images/txt2.png") +
"' border='0'/>" ); %>

Dynamically change Facebook share thumbnail in ASP .Net

I used Facebook like button in ASP .Net my web site master page and when sharing page link in Facebook. I want to change the thumbnail attach with link to each pages, I get image url back end of my asp website and assign to variable and when I'm trying to bind it to front end as below it doesn't get actual value
<link rel="image_src" type="image/jpeg" href=" <% = ImgLink %>"/>
(ImgLink is dynamic variable I got from my back end of code ) at least it doesn't suggest in visual studio.
Try
<asp:PlaceHolder runat="server">
<link rel="image_src" type="image/jpeg" <%= "href='" + ImgLink + "'"%>/>
</asp:Placeholder>
Here is a detailed explanation why this is working.
LitFacebook.Text = "<a name=\"fb_share\" type=\"button\" share_url =\"http://kidstrail.inoday.co.in/\"></a>" +
"<script " +
"src=\"http://static.ak.fbcdn.net/connect.php/js/FB.Share\" " +
"type=\"text/javascript\"></script>";
On Design Page, Take a Literal control:
<div style="float:left; height:18px; margin-left:3px; overflow:hidden;"><asp:Literal ID="LitFacebook" runat="server" ></asp:Literal> </div>

Simplest Ajax Photo Gallery

I don't think "simplest" is subjective.
Looking for a hostable photo gallery that does nothing but show an image and provide "next image" and "previous image" but all without reloading the page. Obviously precaching would be nice too. PHP, Python, Ruby, or JS.
If you want simple, maybe something like this?
<html>
<body>
<div>
<img id="image">
</img>
</div>
<table>
<tr>
<td onclick="getImage("previous");">Previous</td>
<td onclick="getImage("next");">Next</td>
</tr>
</table>
<script type="text/javascript">
counter = 0;
nextImage = new Image();
previousImage = new Image();
getImage = function(what) {
if (what === "previous") {counter--;}
else {counter++;}
nextImage.src = "http://www.example.com/image?data=" + (counter + 1);
previousImage.src = "http://www.example.com/image?data=" + (counter - 1);
document.getElementById("image").src = "http://www.example.com/image?data=" + counter;
}
</script>
</body>
</html>

ASP.net mvc how to comment out html code in page

Is there an easy way to comment out a loop which renders some html and has inline html without deleting anything? I am copying and pasting some code from another project to rebuild a new public front end from a working internal backend.
Below is an example of a sitation in which it would be nice...in asp.net MVC 2
<%
List<VehicleBodyTypeListItem> lstBodyTypes = (List<VehicleBodyTypeListItem>)ViewData["ddBodyType"];
foreach (VehicleBodyTypeListItem bodyType in lstBodyTypes)
{
%>
<a href="<%= Url.Action( "Search", new { BodyTypeID=bodyType.BodyTypeID, BodyType= Url.Encode( Html.WebLinkify( bodyType.BodyType))}) + (string)ViewData["httpCriteria"] %>">
<%= Html.Encode( String.Format( "{0} ({1})", bodyType.BodyType, bodyType.Count.ToString())) %> </a>
<br />
<%
}
%>
I have not completed the method that populates this list yet, and have about 5 more like it further down the page.
The keyboard shortcut is, if you select the section you want commented out is: CTRL + K + C will comment out code. CTRL + K + U will uncomment the code.
Comment a block of code by enclosing it in #* and *#
Do you mean adding comments to the code. If so you just need to add //. Like here:
<%
List<VehicleBodyTypeListItem> lstBodyTypes = (List<VehicleBodyTypeListItem>)ViewData["ddBodyType"];
foreach (VehicleBodyTypeListItem bodyType in lstBodyTypes) // Here there's a comment
{
%>
<a href="<%= Url.Action( "Search", new { BodyTypeID=bodyType.BodyTypeID, BodyType= Url.Encode( Html.WebLinkify( bodyType.BodyType))}) + (string)ViewData["httpCriteria"] %>">
<%= Html.Encode( String.Format( "{0} ({1})", bodyType.BodyType, bodyType.Count.ToString())) %> </a>
<br />
<%
}
%>

Resources