Generate URL Inside A Controller In ASP.NET MVC?
Feb 2, 2010Is there a way to generate URL inside a controller? I want to do the following inside a controller instead of a view.
<% =Url.Action("Validate", "Home", New With {.ValidID = ID})%>
Is there a way to generate URL inside a controller? I want to do the following inside a controller instead of a view.
<% =Url.Action("Validate", "Home", New With {.ValidID = ID})%>
What is the best way to handle a function that might occasional fail to evaluate, but even when it does fail does not require a halt of the parent routine, though sometimes might require an explanation to the user?I have such a function, deep in my code, that returns a number. Codingwise, the simplest approach would be to make the function nullable, and return null when it can't evaluate. That way the calling routine can continue while also knowing the function failed to return a number.
However, depending upon the circumstances, sometimes I want to display the reason for the fail to the user so they know what to fix. Obviously just returning null isn't enough information. Should I be raising messages inside the function itself as it evaluates for anonymous listeners to catch, to be displayed if desired?(For those rightfully pointing out that logic functions shouldn't be responsible for creating user messages, I didn't mean to imply the function generates the full text message, just somehow transmits the reason for the problem so that the UI could later parse that into a message)
The other option I suppose would be throw exceptions inside the function if it can't evaluate, then catch and interpret to user messages if desired. However, as stated the inability to evaluate typically does not signify a halt to the routine, and now I'd have to put a Try...Catch block around the function call everytime I use it.
I would like to get JSON result from another Controller and pass it back to client,here is the scenario:
using JQuery Client request for JSON from Controller A -->
Controller A pass parameter to Controller B and get's
JsonResult --> Controller A pass JSON back to Client.
What is the best way to approach this scenario??
I have a blackbox (with a crude ftp server on it) which has an IP address, a file on it, a username and a password. I have a PC logged on to the local network and I want to write a VB.net program that sits on the PC and when the file is created it downloads that file. from the laptop I can type ftp:192.168.43.34 in to windows explorer and see the file without having to type in a username or password (username is set to Anonymous)I require a simple program that just points to the file (ftp:192.168.23.12/banjo.txt) and grabs it to a local path (C:\banjo.txt)I have looked everywhere and not found anything that works and not interested in paying $500 for a library.
View 4 RepliesThe default code that VS generates for HomeController is[code]...
Consequently, I was wondering if the "GET " blob of text actually does anything and if it is possible to fiddle with URLs without diving into the ASAX file.
i have a application thats writen with the pylons framework. Now i want to call some controllers from a vb.net application. How should i do this? I've tried it like this:
Dim webclient As New WebClient
Dim dataStream As IO.Stream = webclient.OpenRead("http://192.168.0.20:5000/controller/default")
Dim reader As New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()
[code]....
But instead of an json object that is generate by the pylons controller, i'll get the html code for the page which is reachable under "http://192.168.0.20:5000"
I made a project where I have a basic DemoController[code]...
I should probably mention that my .aspx file is in another project than the web app. I build everything into a dll then put that into a folder in my web app project. The error I am getting is "The view '~/Views/Demo/Index.aspx' or its master was not found or no view engine supports the searched locations. The following locations were searched: ~/Views/Demo/Index.aspx"
I'd like to do a kind of overload of the actions in the controller.
Is it possible? 'Cause I havn't found any info about it. And when I tryed, I got this error.
The current request for action 'Create' on controller type 'InterviewController' is >ambiguous between the following action methods:
System.Web.Mvc.ViewResult Create() on type
[Code]....
I've tryed few things to get what I wanted. The last one was to copy what was done in the "Edit" action, but for an empty rank. (so I created an empty rank in my DB). I don't think it was a good idea (imagine someone wants to update the DB where idOpportunite = 5...)
I'm looking to pass the value selected in the drop box when I click submit. Instead, it's passing a null value and I'm confused as to why.[code]...
View 2 RepliesI've been working with code that polls a USB controller for changes using DirectInput, however I would much prefer I could make it event-driven instead (to cut CPU usage). Does anyone know if there is some method of doing this with DirectInput? I can provide the code upon request.
View 1 RepliesI have an application that has multiple UI layouts, sometimes on tabs, sometimes the occasional separate form.I recently bought a pack of UI elements, and I'd like to use a ribbon control as the main navigation. For the most part I want the tabs on the ribbon to function like your everyday tabcontrol. The problem is that the ribbon tabs don't each have their own page for you to lay out your controls like the normal tabcontrol does.So right now I have the ribbon control at the top of an MDI form, and instead of using multiple tab pages I have many borderless forms, and when I click on a tab of the ribbon, I maximize the appropriate form and bring it to the front. This creates the illusion of tab pages by eliminating the control boxes of the child forms.
View 3 RepliesI don't know what I've done bad, or what could have caused this bug : when I submit this form to the controller, the controller receives 2 empty fields here is the form inside the view :
@Using Html.BeginForm("contactSearch", "search", FormMethod.Post)
@Html.TextBox("SearchString")
@Html.DropDownList("opportunite", "Choisissez une opportunité")
@<input type="submit" value="Submit!" />
End Using
[Code]...
I would like to use a Logitech wireless game controller. I imagine such a custom control already exists as a VB 2008 .net class library. I've tried to search MSDN but can't find anything.
View 1 RepliesI am wondering what I am missing in the attached code that is making it impossible for me to make the VB.NET program below work using MVC (Model-View-Controller). Right now, I am really lost despite my best efforts...
I am trying to implement the observer pattern and think that my code is getting closer to MVC but not quite there yet, firstly because it wont even run ... nevertheless I know that there is someone out there who knows what I am doing wrong and I would definitely benefit from any guidance or help that someone more experienced in MVC VB.NET implementation can give .. hence this letter.
[Code]...
I know how to send data to com or virtual usb-com if it has physical com port number listed under "Ports (COM&LPT)" tab in the Windows device manager
' sending to device with physical COM port number"
Try
Dim searcher As New ManagementObjectSearcher( _
[Code]...
But how to send data to the device listed in "Universal Serial Bus Controllers" tab without any physical COM port number?
I have built an application a while back and now think that performance would benefit from a MVC approach, so I am looking into that. If I were going to do this, I would need the controller to be able to replace itself. That seemed like it may be a problem, so I created a Hello World application to test it. Here's the
Form1.vb:
Public Interface IView
Property Controller As a_Controller
[Code]....
I have 2 questions:Will the 'old' controller objects still be in memory? Seems this could be a serious memory management issue after a lot of changes. It was my own decision to implement the factory in a module. My examples did not do this.
i know how to make it but i want to know how to make tap controller as web browser.
View 6 RepliesI have a PlayStation USB controller and want to discover how to test the buttons and controls on the device from vb.net. Is there documentation anywhere on how to get info from a usb controller? I'm not even sure which department or category this falls
View 5 RepliesI've got an .aspx page with this in it:
<%@ Import Namespace="System.Web.Mvc" %>
<%= AssetController.ScriptTag("/js/Community/CommunityWizard.js")%>
And I have an AssetController class:
Imports System.Web.Mvc
Public Class AssetController
Inherits Controller
[Code]...
What gives? I don't understand why I can use this controller everywhere in our ASP.NET Forms/MVC hybrid application, but not in a view.
EDIT: In fact, when I type <% System.Web. into the .aspx view, Mvc doesn't even appear in Intellisense!
I have a table with several rows of data that I need to return to the controller. In my view, I initially load the table by selection of a time period and clicking a button. The table loads all my relevant records but one of my table cells contains a dropdown list. So I should be able make a selection in the dropdown click "update" and my controller saves the changes.
So everything works until I try and save. The model that is sent to the controller is completely null. The list property I have tied to the table cells returns to the controller null.
[Code]...
NOTE: This is written in VB.NET but C# help is welcome. I am familiar with both languages in MVC.
i m currently working on application that has to monitor temperature and humidity of a particular place and constantly report the same to the user over internet. So far, I m using LPC1768 and its ethernet module collect the data, process it and send it to the router. On the other side, i have a computer which is connected to the same router and running a VB application where the data is mined and reported in a excel.
This setup works just fine. Now, i want to monitor the same data over internet. How can i do the same?
Here i was able to connect to the micro-controller using the IP 192.168.1.100 port 80. I m aware that the IP is a local one and to access the micro controller from Internet there is another way.I have a IP based webcam which enables us to monitor from internet. How should i make micro-controller data be accessible from internet.(similar to IP Camera).
In my MVC Web App I am running an ActionResult with the following signature: Public Function Create(ByVal article As Article_Ad) As ActionResult And in my ASPX page I have declared the following form which fields correspond to the model, which is strongly typed:
[Code]...
I want to be able to make my xbox 360 controller be used as kind of a mouse how can I do this?
View 2 RepliesWhen I click save on the view, the model being sent to the save method of the controller has no values set, they're all default values. I'm actually using the exact same technique from another project... The data is populated just fine in my view, I can edit it and click save, the code enters the SetSiteTerms method in the controller but has none of the data from the view.
Model:
Imports System.ComponentModel.DataAnnotations
Imports System.Runtime.Serialization
<KnownType(GetType(SiteToA))> _
Public Class SiteToA
<ScaffoldColumn(False)> _
Public Property ID As Integer = 0
[Code] .....
I've updated my view and controller. Why my model is populated, can be editing in the view but when I post with the save button, the model sent to the controller has no data???
I am writing my first MVC application, and struggling with how best to pass data from my controllers to my views. I have a very simple XML document structured like this. (Yes, this is Magic: The Gathering data)
<setlist>
<set>
<name>Alara Reborn</name>
<block>Shards of Alara</block>
<cards>145</cards>
[Code]...
But I get an Object Block or With Block error when trying to access SelectSingleNode("block") on the second "set" node, since that node doesn't have a "block" node.I also have a feeling that the way I'm approaching the view is all wrong. Is there a better way to get this simple XML data into the view so I can work with it?
Currently I have a aspx page that is defined as[code]...
How do I change this so that the javascript fires, runs my validation and then hits this controller action?
How to pull the listing of all the domain controllers from the LDAP server in VB.net 2008. The reason I want to do this is so that I can check each domain controller, one at a time, for the account lockout status of an ID. Right now I use a class with 1 function to pull all of the user properties I need. So far it's pulling from only 1 domain controller.[code]...
View 11 RepliesI am looking to buy Xbox 360â„¢ Universal Media Remote or Harmony® Advanced Universal Remote for Xbox 360® to use on my application. Is it possible to use them from vb or csharp?
If it's possible where should i be looking for some infomation?
I was just wondering if there was a way to send the button value of a button on a controller to the controller. What I mean is, if the xbox 360 controller was a windows form, clicking the mouse on one of the buttons would be like regular button presses, and then the button.performclick for that button would also press that button. Does anyone know of a way to do this?
View 2 RepliesIn the MVC design pattern we must use a controller(s) classes.
What are the fucntions (features) of the controller apart from handling communication bewteen Model and View?e.eg; can we include input validation code in the controller?