my question is the following
I need to change a menu in this page, but how do I recognize how this page was written.
Normally, I do stuff in php, but this is new to me.
I can see the words asp and c#, but it is not developed as a "dot net thing", is it?
..otherwise I would need visual studio, I guess?
the homepage code
<%# page language="C#" autoeventwireup="true" inherits="_Default, App_Web_npdtwtc3" masterpagefile="~/Site.Master" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script type="text/javascript" src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.2.74.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('.slideshow').cycle({
fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
});
});
</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<p align="left">
<br />
<br />
<br />
<br />
<font size="9">Multi Mind</font> <br /><br />
<IMG SRC="images/contactgegevens3.png" ALT="" ALIGN=RIGHT><br />
Tax Recruitment is de specialist op het gebied van arbeidsbemiddeling voor fiscalisten.<br />
Het richt zich
thanks, Richard
It appears to be a ASP.NET Web Forms page (ie. .aspx).
So mostly mark up, either run on the server (elements with runat="server") or client (other HTML elements) but there is some JavaScript using JQuery.
For an introduction to ASP.NET Web Forms try here (this is .NET v4, but has links to the pages for earlier versions): http://msdn.microsoft.com/en-gb/library/ms178125.aspx
It's an ASP.NET Web Site or Application (someone help explain the difference in this context) and that particular file is an ASP.NET Web Form. There's generally no need for Visual Web Developer, you could use any text editor really - but it sure makes it easier.
Note that your example uses master pages so you're only looking at the unique content for that particular page - the menu you're after is likely the same across different pages (?) and hence specified in a master file (the name and path to it is defined on the first line). Perhaps looking at that file would make things clearer.
This is ASP.NET with C# as the code-behind. Also a little bit of javascript in there. You will most likely need Visual Studio to edit this easily. You can get visual studio express for free from here:
http://www.microsoft.com/visualstudio/en-us/products/2010-editions/express
Good luck with your work.
As stuartmclark mentioned, this is an ASP.net page with C# as code behind language. To explain this,
language="C#" tells you that the code behind is C#. If you are now aware of code behind concept, you can think of this as server side script.
asp: anything starting with asp: are the ASP.net controls. This tells that this is an asp.net page.
And yes, to work on this you need either Visual Studio or Visual Web Developer. You can downlaod Visual Web Developer from here. It's free (as in free beer) from MicroSoft.
Hope this will clarify your doubt.
Related
The issue I describe here affects only my development machine. Deploying to different servers (Test and Production) do not exhibit this behaviour.
I have a simple ASPX (ReportViswer.aspx) page that contains a DevExpress Report Viewer in it as follows:
<%# Page Title="" Language="C#" MasterPageFile="~/SiteV2.Master" AutoEventWireup="true" CodeBehind="ReportViewer.aspx.cs" Inherits="MyApp.Platform.Reports.ReportViewer" %>
<%# Register Assembly="DevExpress.XtraReports.v16.1.Web, Version=16.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.XtraReports.Web" TagPrefix="dx" %>
<asp:Content ID="cntPageTabs" ContentPlaceHolderID="cphPageTabs" runat="server">
<ul class="nav nav-tabs">
<li class="active">
Page
</li>
</ul>
<div class="tab-content tab-content-for-page">
<div class="tab-pane active" id="tab-page">
<asp:Button ID="btnToolbarClose" runat="server" Text="Close" CssClass="btn btn-default" OnClick="btnToolbarClose_OnClick"/>
</div>
</div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cphMainContent" runat="server">
<dx:ASPxDocumentViewer ID="ReportDocumentViewer" runat="server"></dx:ASPxDocumentViewer>
</asp:Content>
The page itself does nothing really clever other than instantiating an XtraReport and assigning it to the report viewer:
protected void Page_Load(object aSender, EventArgs aEventArgs)
{
if (!IsPostBack)
{
if (Session["ReportParams"] == null)
{
ShowErrorMessage("No report information was passed.");
return;
}
ReportParametersHelper reportParams = new ReportParametersHelper();
reportParams.Deserialize(Session["ReportParams"].ToString());
XtraReport reportToView = null;
switch (reportParams.ReportName)
{
case ReportNames.REPORT_DISCOVERY_DOCUMENT:
reportToView = new ReportDiscoveryDocument();
(reportToView as ReportEmailMessage).Activate(ReportParams.Params);
break;
}
}
}
The WebForms 4.6.1 solution is running against IIS 10 on Windows 10 on my development machine and when I try and open the above page via a simple Response.Redirect(~/reports/reportviewer) I either get prompted for a username and password:
or ultimately a resource not found error:
The application is running against the DefaultApp pool that is configured as:
So my questions are:
Why does this work on production and staging and not on my development machine (ie ReportViewer displays just fine with no issue)
Is there perhaps a correlation with the fact that IIS things this page is .NET 2.x? (see screenshot)
Any ideas on how to debug this? I cannot develop reports on this machine.
DevExpress has been unhelpful as they want a small sample project - and while I understand that the test harnesses do not exhibit this behaviour so it is something in this much larger project.
So any insights or ideas would be appreciated and I am happy to provide more diagnostics information as required.
This issue is likely caused by your development machine routing settings rather then by DevExpress components. If this is the case, you will be able to reproduce it even if you remove the ASPxDocumentViewer control from your WebForm.
Try passing the following route format to your Response.Redirect method "~/reports/reportviewer.aspx". This is the default ASP.NET WebForms route format, and when you are using the "~/reports/reportviewer" IIS attempts to open the folder rather then a web page, so the authorization is requested and 404 error is thrown. This issue is not reproducible on another machines because of different routing settings.
See the ASP.NET Routing MSDN article for more information on how routing works in ASP.NET.
I searched a way to include a file in a web application (like a menu, so I won't have to edit it on all pages when applying changes), but haven't found something as simple as
<?php include "Menu.html"; ?>
Can you please help?
Have you looked into Master Pages? They would certainly help you add the same layout across several pages.
Or perhaps you want a reusable User Control (that you write yourself)?
We don't use "include page" in asp.net, even though it is possible (with a different syntax of course). Instead, have a look at Master page concept.
MasterPages allow you to maintain a parent/child relationship between a master page which contains content that wraps around any number of child content pages.
Similarly, UserControls allow you to re-use whatever content you want on whatever page you want, whether it's a MasterPage or ContentPage:
<%# Page Language="C#" %>
<%# Register TagPrefix="uc" TagName="Spinner"
Src="~/Controls/Spinner.ascx" %>
<html>
<body>
<form runat="server">
<uc:Spinner id="Spinner1"
runat="server"
MinValue="1"
MaxValue="10" />
</form>
</body>
Methods (C#)
Executable code:
Page include
<!--#include file="a.aspx"-->
Execute independently inside a page
<% Server.Execute("a.aspx"); %>
Non-executable code:
<% Response.WriteFile("a.inc"); %>
I believe this is what you are looking for.
<!--#include file="wisdom.aspx"-->
I use C#.net
<% Response.WriteFile("YourPage.aspx"); %>
and this works real well for me!!
I also use your line,
<!--#include file="wisdom.aspx"-->
when I am in HTML mode.
Since there is no more code behind in .aspx pages in .NET MVC, It seems impossible to declare a function or method direclty in the .aspx page (the view).
In classic ASP, I could add a script tag with runat="server" to declare a local function.
Each client has its own view. The method in the controller send the right view to the right client.
What I'd like to do is to change some method logic depending of the client. Since this is highly dynamic,I don't want to add a class or a method in the controller then rebuild and upload in production each time we have a new client.
So I thought of adding some logic directly in the view. Is this possible?
In classic ASP, I could add a script tag with runat="server" to declare a local function.
I guess you mean in classic WebForms, because in classic ASP the runat="server" attribute doesn't exist.
So you could do the same in an ASP.NET MVC view using the WebForm view engine:
<%# Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script runat="server" type="text/C#">
public string Foo()
{
return "bar";
}
</script>
<div><%= Foo() %></div>
</asp:Content>
Now whether this is a good idea and if you should do it is an entirely different topic.
I need to make a quick demo showing how to do interactivity on an ASP.NET MVC page.
I opened an ASP.NET MVC project in Visual Studio 2010, put the view in design mode, dragged in a button, double-clicked on it and looked at the view again. I was expecting to see some ingenious JQuery code generated but instead an <asp:Button> and a <script runat="server"> block was created, which seems to be a mixing of classic ASP.NET and ASP.NET MVC metaphors. I don't think that is the recommended way to build interactivity in MVC, right?
So what is the easiest, most standard-MVC approach for me to (1) create a button, (2) when the button is clicked, change some text in my view?
is it really best practice in MVC to use the runat-server block?
are there some easy wizards which generate JQuery interactivity so that I can do this in a best-practice MVC way?
or do I need to implement the JQuery myself as I would on a plain HTML page without ASP.NET MVC?
View:
<%# Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
}
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Home Page
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<form id="form1" runat="server">
<h2><%: ViewData["Message"] %></h2>
<p>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</p>
</form>
</asp:Content>
You should not use asp.net ajax controls in asp.net MVC.
If you want to create a button just write some old-fashioned html like:
<input type="button">Button</input>
then if you need this button to make some action, just write new action instead of code behind method like and call it like:
<input type="button" onclick="javascript:window.location = 'http://mypage.com/mycontroller/buttonaction' />
or even better create a link instead of button by using mvc builded-in html helpers:
<%= Html.ActionLink("Do something" ,"ButtonAction") %>
Faster you catch it better for you. You need to resign from asp.net ajax habit. There is no postback or code behind and it's removed with a reason. MVC is controlled by executed actions which means that you are steering the application by calling specified links. By using pure html you've got lot more control on your output code and flow of actions in your application.
Remember that MVC is not a new ASP.NET AJAX and those two will goes together, so if this style of writing we apps does not suits you then you do not need to use it. It's just the metter of choice which technology is better for you and your projects.
Also to learn more about mvc visit asp.net mvc webpage. I specially recomend you to see some videos like this one. It will definitely help you to better understand what mvc is and what are it's advantages and disadvantages.
I love the calendar extender, but I am unable to use it in my MVC app. How do I connect the calendar extender to a textbox in MVC... or add the extender at all for that matter?
Old Way...
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
...
<asp:TextBox ID="txtDate1" runat="server" ValidationGroup="DateCheck">
</asp:TextBox>
...
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
...
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtDate1">
</cc1:CalendarExtender>
Yes you can - if you use the Microsoft Ajax libraries. Link here. Calandar code here.
If you go to Stephen Walthers bolg - here I'm sure there's an example of using the server side controls if memory serves me correctly.
Why not use the JQuery UI datepicker?
See JQuery UI DatePicker
You have to setup your view like a web form, or use a web form within the MVC application, as it requires a form with runat server and a scriptmanager on the view page.
I found the solution. A pretty helpful step by step link that gave me EXACTLY what I want...CodeSprouts.com helped me out alot. Thanks for the directions!!!