C# - NVelocity Syntax For Calling Methods With Evaluated Parameters?
Jul 14, 2010
I have a fairly simple template that I need to make a method call from. However, NVelocity does not seem to evaluate method parameters that themselves are NVelocity variables. Take the following NVelocity template:
#if (--- CONDITION SNIPPED ---)
<blockquote class="column span-4">
I MADE IT!
</blockquote>
#else
<blockquote class="column span-4">
$extensionMethods.TestMethod(${var1})
</blockquote>
#end
In the above template, $extensionMethods is passed in as an instance of a class and works wonderfully when passing in evaluated numbers (e.g. $extensionMethods.TestMethod(4) works every time). However, using $var1 causes the entire string to be returned as-is: $extensionMethods.TestMethod(${var1}).
Is there a way to pass in a variable to a method lazily to get the above template to evaluate correctly?
View 1 Replies
Similar Messages:
Feb 9, 2010
What is the syntax for an not true or false if statement in nVelocity (or Velocity)?
And more importantly, where is this in the nVelocity docs? I've been Googling for quite a while to no avail.
I've tried several different combinations such as:
#if (!$artist.IsFestival)
$artist.FestivalName
#end
and
#if ($artist.IsFestival == false)
$artist.FestivalName
#end
So frustrating!
View 1 Replies
Oct 29, 2010
When are declared values bound to properties of a user control in WebForms?
I have a user control which has a public property which is an enum type. In my aspx page I'm setting it's value declaratively. In the ascx I'm outputting the value to the page using <%= %> syntax. The value that is output by the echo syntax is always zero 0. The enum does nopt have a zero value.
My question therefore is, is echo <%= %> syntax evaluated before the declared value is bound to the property?
[code]....
The output is :
<a href="foo.aspx?foo=0">Foo</a>
<a href="foo.aspx?foo=0">Foo</a>
<a href="foo.aspx?foo=0">Foo</a>
I'm going to assume that zero is the "unset" value for any enum member and therefore assume that <%= is executed before the value is bound to the property.
View 1 Replies
May 27, 2010
In my asp.net application, I am using wcf service to get all the business logic. I am using that service reference in my application to work with that. Now adding that service reference is giving another option Update service reference is giving Generate asynchronous operations. If I check the option and add the service will it generate asynchronous methods for my existing service. If so how do I use the metohd.
View 1 Replies
Aug 3, 2010
I Wrote code to copy Client side DB to Server side by providing the credentials required. I have a simple form, Containing three textboxes and submit button. the textboxes takes UserId,Passwd and Servername of ORACLE(Client Machine's) and when user press submit button. the VB Script method invoked. here the function follows.
Public sub DBConnect()
Dim con,usr,pwd,server
usr= form.User.Value
pwd = form.Passwd.Value
server = form.Connect.Value
Dim strcon
strcon = "Data Source=" + server + "; User ID = " + usr + ";Password=" + pwd + ";"
con.open strcon
dim rs,str
str = "select * from emp"
set rs= con.Execute(str)
if rs is not nothing then
PageMethods.SendForm(rs)
end if
End sub
Here I am getting the record set this record set I have to access in the serverside to copy the values to my datatable. How can I acheive this? How to call Page methods through VB Script. Here is my Page method.........
View 4 Replies
Nov 15, 2010
I have created a table adapter in DAL. I have created a gridview in the page and want to fill the gridview with a table data by calling a method. My table has 11 columns but i want to display only 2 columns of the table. My getSong() method has a query as Select title, category from Muisc. But it diaplyas all columns with no data except title and category and the autoincrement primary key column with negative values. The pic is given below. How can i solve it?
View 2 Replies
Jun 29, 2010
In the create aspx page i have 2 buttons. One for creating the new customer and another one for searching the customer based on the customer last name. Now the issue is when i try to search the customer based on the last name the page is calling the create action method only, not the search action method. how to call a spicific action method from the buttons. I know it can be done using ajax post back but what i am looking at is to achive this in the normal post back itself.
View 3 Replies
Jan 20, 2010
Is there any possibility to pass values of form elements to action methods but using parameters?I have a form with a lot of input fields and the method signature will get pretty long. Besides the form elements depend on each other so if the user makes a special choice only a subset of the form elements should be displayed so there are several combinationof values to be passed.Can I access the posted values in a generic way through a collection in the controller or something similar?
View 3 Replies
Jan 18, 2010
This is doing my nut in,
Dim sa As New SqlDataAdapter("C_CUSTOMER_SEARCH", ConfigurationManager.ConnectionStrings.Item(1).ToString)
Dim ds As New DataSet
Dim dt As DataTable
sa.SelectCommand.Parameters.Add("LASTNAME", SqlDbType.NVarChar, 20).Value = Request.QueryString("LASTNAME")
sa.Fill(ds)
dt = ds.Tables(0).DefaultView.ToTable()
gvReport.DataSource = dt
gvReport.DataBind()
In the SQL tracer, I get:
exec sp_executesql N'C_CUSTOMER_SEARCH',N'@LASTNAME nvarchar(20)',@LASTNAME=N'smith'
An 'Incorrect syntax near' sql error bubbles upto the ASP.NET runtime. Running this in SQL studio also causes the same error. What is causing this error?
I would also like to know if its possible, to add QueryStringParameters to the SqlDataAdapter or not. I've tried (not very successfully I might add), to add QueryStringParameters programmatically to both SqlDataSource and SqlDataAdapter objects which have been created in code and not in the Markup. But each time I get 'nothing' when I call the Select() method on the SqlDataSource.
View 2 Replies
Dec 23, 2010
the problem i am having is passing in multple parameters are part of my Function(p) call... i'll explain further..
This is my interface: it might have errors further though through this is still in development..
IRepository:
[Code]....
This is my repository, inheriting the interface above
[Code]....
And finally in my code-behind i am calling the SingleEntity - this is where i must be going wrong....?
If i call it with a single parameter then it's fine.. multiple and it goes awry..
I have put comments in the section i can't seem to figure...
[Code]....
When i run the code i get the following error:
[Code]....
View 7 Replies
Dec 27, 2010
I'm trying to call an action method in an MVC application using jQuery. Basically what I want is to take the value of a couple of input fields and call the action method by clicking a button, passing the values of the input fields as parameters. But I only get the value of the "number" parameter, not the "year" parameter.
function selectWeek() {
$('#selectWeekButton').click(function (event) {
var number = $("#selectWeekId").val();
[code]...
I checked the url with an alert, as you can see, and it seems to contain both values fine. But when I check the value of the year parameter in the action method it is null.Here are the input fields:
<span>Vecka: </span>
<input type="text" id="selectWeekId" />
<span>År: </span>
<input type="text" id="selectYearId" />
<input type="button" value="Välj vecka" id="selectWeekButton" />
And the beginning of the action method:
public ActionResult Edit(string number, string year)
//etc...
I know that this looks like a strange thing to do instead of just binding fields, but the reason is that these input fields and their values is not the main purpose of this View. They're just there to select another week in this timesheet application. And besides, I'm going to replace the input fields with a jQuery calendar eventually, so I will still have to do something like this.
So what's the easiest way to do this, and why isn't it working as it is?
View 2 Replies
Feb 25, 2011
I have a JQuery template, and I want to call a webservice and populate the fields in it. The issues I am having are, I'm not sure how to pass parameters in my $.ajax call (ideally, I want to pass a dictionary so I can pass as many or few parameters as I want). I tried data: { Key : Value } but get a 500 server error saying something about not a valid JSON primative.
Once the webservice is called, how can I get my data back in a JSON string that is compatible with a JQuery template? My webservices usually get a List and my jquery template works with a JSON object.
The problem is basically the format of data between client and server. My webservice call works fine, it's simply a problem of JSON and data. Edit: I have succeeded in calling the webservice with a dictionary, I am now trying to figure out how to get the data back. I'm getting a circular reference error.
View 1 Replies
Jan 24, 2016
I am calling server side methids from client side using PageMethods. Can those methods return value back to client side. If yes then how and if no then how can that be achieved? refer to my code below.
function getValuesFromPSS(s,e)
{
debugger;
[Code]....
View 1 Replies
Jul 15, 2010
I have a page which submits a form in my local system but in my production system when i click my submit button it just freezes with the error in my web developer toolbar saying Error: Sys.WebForms.PageRequestManagerServerErrorException: When calling stored procedures and 'Use Procedure Bodies' is false, all parameters must have their type explicitly set.
View 1 Replies
Jun 30, 2010
I did some research after posting. All I found was simple examples for no-layer architectures, like connecting to a database from your aspx page, so, in a corporate environment, it is unnaceptable.
I need to call a server-side method (using ASP.NET Ajax) in a 3-layer architecture.
For example, my Default.aspx contains a method LoadProducts().
[Code]....
[Code]....
This cannot change. There is no way to convert Business and Data layers to static.
How can I call the LoadProducts() method using ASP.NET Ajax?
View 2 Replies
Apr 9, 2010
Is it possible to call usercontrol methods/events using MSAJAX. I wanted to update my usercontrol by calling one of its events when a property from its parent page changes.
View 2 Replies
Nov 29, 2010
If I had the Linq sentence:
var MyDC = new MyModel.MyDataContext();
var MyValues = from p in MyDC.Patio
where p.LoginID == loginId
select p;
Let's say that I have a second variable: MyCurrentTable which could be equal to: Patio, Furniture, Warehouse, Company, etc. depending on the table being used at any given time
From there, how can I get to a kind more generic kind of construction, like this one (for sure I know that the syntax I am using is not ok
var MyValues = from p in ({0}.{1}, MyDC, MyCurrentTable)
where p.LoginID == loginId
select p;
Where MyCurrentTable could be: any table at any given time, having this piece of code to work in a recyclable way, valid for any table.
View 1 Replies
Mar 17, 2010
I'm looking to use NVelocity in my ASP.NET MVC application, not as a view engine, just for rendering some email templates.However, I cannot for the life of me get it to work. I have downloaded it from the castle project and followed the example at [URL].html#step1No matter what I try I don't seem to be able to load a template located in my site. The example suggests using the absolute path, which I have tried to no avail:Template t = engine.GetTemplate("/Templates/TestEmail.vm");So please can someone give me two examples. One of loading a template located in the web site directory and secondly one parsing a string variable (as it is likely that my templates will be stored in a database).
View 3 Replies
Feb 1, 2011
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.
View 1 Replies
Dec 11, 2010
I have a ListView displaying data from Table A using a SqlDataSource.
I want to take the displayed data (and these are just the standard columns representing fields in Table A) and store them in Table B using a Stored Procedure
(The scenario is much more complex but I've left out anything not relating to this exact problem).
I've added a Button to the ListViews ItemTemplate and I'm using OnItemCommand to create a Sub for its "Click" in the Code Behind.
This is a simplified chunk of the SQL I'm using to insert the ListView's fields into Table B using the Stored Procedure "InsertCart":
[Code]....
Where I've highlighted "Description" in the last line. In a GridView, this would be enough. Description is a Column name in Table A and B and iy's an Item in the ListView. But I'm realising that, with ListView's, the data binding is not as "automatic" as a GridView. Just using the columnname is not enough.
What do I use instead of the word Description to reference this column in the Parameter?
View 2 Replies
Nov 28, 2010
I have a repeater in my page as follows:
<asp:Repeater ID="RepeaterVacancies" runat="server">
<ItemTemplate>
<asp:TableCell CssClass="evenTd" runat="server">
<asp:HyperLink runat="server" NavigateUrl="Vacancies.aspx?VID=<%#DataBinder.Eval(Container.DataItem,'id')%>"
ID="Hyperlink1">
<%# Container.ItemIndex + 1 %>
</asp:HyperLink>
</asp:TableCell>
......
</ItemTemplate>
</asp:repeater>
when I loaded the page, the numbers come fine, but the links are not evaluated well: Instead of linking to Vacancies.aspx?VID=170 for example, the link comes this way: [URL]
View 3 Replies
Sep 19, 2010
First time using parameters, not having much luck. Keep getting 'invalide syntax near '/' when trying this code.
string strConnString = ConfigurationManager.ConnectionStrings["WebConfigConnectionString"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(strConnString);
SqlCommand sqlComm = new SqlCommand();
sqlComm = sqlConn.CreateCommand();
sqlComm.CommandText = @"DELETE FROM Assets WHERE Image = @/Images/mypic1.jpg";
sqlComm.Parameters.Add("@/Images/mypic1.jpg", SqlDbType.NVarChar);
sqlComm.Parameters["@/Images/mypic1.jpg"].Value = "Image";
sqlConn.Open();
sqlComm.ExecuteNonQuery();
sqlConn.Close();
View 1 Replies
Jan 22, 2010
I am an experienced .NET developer with approximately 5 years of experience. Unfortunately, I have worked primarily on the back-end and as an desktop/smartclient developer. I have worked as a consultant for a total of 1 1/2 years on web development using both the MVP pattern and some Silverlight. I am wanting to develop a personal site, (My wife is due with our first in 7 months!) and figured while I was at it I would target particular technologies that I want to learn. Being that my current employer
uses Monorail with NVolocity and is plannning a migration to ASP.NET MVC with (most-likely) NVelocity, I figured that would be a good tech stack to use. In addition, I would like to add JQuery to the set-up.
I have done several ASP.NET MVC tutorials. Including one on this site (Great job!). However, adding NVelocity and JQuery to the mix muddies the water a bit for me.
So, my question is, does anybody have advice of where to start? Do you know of any good books, online tutorials, etc.? Do you think this is a good stack to use? Better view engine?
View 2 Replies
Oct 31, 2010
Is there any way to use placeholder similar to WebForms in NVelocity View Engine (.vm files)? Today I've got a component containing everything for the <head>, but I wish to specify additional tags from each view page like it can easily be done in ASP.NET WebForms / MVC:
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server"></asp:Content>
If this is not possible directly trough NVelocity View Engine, do I have any other alternatives other than using a blank MasterPage and adding all markup in each view page?
View 1 Replies
Aug 8, 2010
I'm having problem in inserting text from a textbox in which user write or copy some text which may contain special characters ( " , . ) etc. If there is any special character it get conflict with CommandText Syntax and generates error in inserting. I want to insert all these characters. How could i do it?
Code:
[code]....
View 1 Replies