I want to use "NVelocity" from plain ASPX pages without using any MVC framework. I don't want to use "NVelocity View Engine" thru' asp.net MVC framework. The only example that I got for "NVelocity" is for merging and writing onto console window (http://www.castleproject.org/others/nvelocity/usingit.html)
I am looking out for example on to integrating "NVelocity" into aspx web forms. Any pointers would be really helpful.
I found a way. The idea is the override Page.Render() method in an aspx page. Write the code in Render() method to transform the HTML template (I mean, *.html file or *.aspx file) using NVelocity. Pass HTMLTextWriter object while merging the template and context "template.Merge(context, writer);"
This will render the transformed HTML to web browser.
Related
Is it possible to create reusable code blocks in an HTML page? I have a table that I want to replicate multiple times in my aspx page and I don't want to duplicate the code.
I've used #helper in Razor before but I don't know of an equivalent tag in aspx.
WebForms and MVC works in very different manners.. In WebForms you create a WebControl, not HtmlHelpers
Here is a tutorial about how to develop a server control in Asp.Net:
https://msdn.microsoft.com/en-us/library/yhzc935f.aspx
I'm a java programmer and for the first time I need to face a VB and ASP.NET web project.
I found some very basic tutorials on how ASP.NET works but I didn't understand very well how the logic behind works.
This project consist of lot of coupled files, the main pattern I found is:
file.ascx
file.ascx.designer.vb
file.ascx.vb
file2.aspx
file2.aspx.designer.vb
file2.aspx.vb
How do these file work and interact? I'm trying to understand it in a MVC logic but I can't seem to get it.
Drop the MVC logic in your head. ASPX doesn't use the MVC (at least by default).
The code files you see are grouped in two:
ascx: markup file. On the fly converted to VB.NET > MSIL;
ascx.vb: the code behind file. This one is merged with the generated code from the markup file (thanks to the partial keyword in the class declaration).
The ascx file is a control file, the aspx file is a page file. A page file can consist of zero or more controls, defined by the ASP.NET team, third party developers or you. If you want a custom control, you can create an own control by creating an ascx and ascx.vb file (or let Visual Studio do it for you).
aspx files usually will have the UI and will which is usually HTML tags, some ASP.NET server control embed code. aspx.vb file (codebehind) will have server-side coding in VB.NET.
In the MVC logic, you can relate aspx page to View and aspx.vb to Controller action methods.
I have a big ASP.Net forms application. I am trying to start adding MVC for new stuff.
But still there are summary pages (in ASPX) where multiple user controls are displayed.
SO I need to embed HTML output of mvc partial page (added as area in existing asp.net web forms app) to ASPX page where other forms user controls are displayed
One way is to get HTML in code behind by initiating http request and place it in literal control.
Other approach i thought was to use JavaScript, but that may not work with convert to PDF etc scenarios.
Please suggest if there is a better way..
Thanks,
Rahul Jain
I've implemented and used a pretty functional grid through this tutorial for MVC:
http://www.codeproject.com/KB/aspnet/AspNetMVCandJqGrid.aspx
I was wondering how to migrate this to ASP.NET WebForms, for another project I want to use jqGrid on, but is written in WebForms instead of MVC.
I've found some examples but they're rather incomplete (require me to declare the columns in both js and codebehind, don't feature paging, no multi-filtering, etc)
Jquery and page methods in WebForms application are working well together. ( http://www.junasoftware.com/blog/using-jquery-ajax-and-page-methods-with-a-asp.net-webservice.aspx )
After glance on the article you pointed to, I think they will work too. Here are what I think you should do.
Including the article above I mentioned, read more on using jquery with page method.
you will be able to reuse most of html and javascripts and c# data structures for communicating with jquery from the article (of codeproject).
What you need to do is that basically, you have to make your page method act as a controller while aspx as views. And adjust other elements accordingly. One thing you have to remember is that page method should be static.
I have an ASPX based component which I'd need to inlude into a plain ASP based
script. Scenario is, that I'm working within an LMS system (Angel to be exact)
and I wan't to create a new nugget within that framework. An Angel nugget is
pretty much what a portlet is in the Java world.
Now, the nugget spec. states that my starting point has to be a file called
default.asp. What I'd like to do is:
read relevant data from ASP session
pass data to ASPX component
have ASPX do it's job and display the results
My problem is that I fail to run / display my ASPX component without
using an iframe, which I want to avoid since that crushes the layout /
design of my nugget.
Is there a way to get this done properly or do I have to rewrite my
component in ASP to get this going?
Note: the component performs
web service queries and such and I'd like to avoid rewriting that.
Why don't you grab the .aspx content from the .asp page using the MSXML object?
url = "http://www.yoururl.com/YourPage.aspx?relevantData=YourRelevantData"
Set xml = Server.CreateObject("Msxml2.SERVERXMLHTTP")
xml.Open "GET",url,False
xml.send
html = xml.ResponseText
Set xml = Nothing
Response.Write(html)