Asp.net - How To Define The ActionLink
Jun 3, 2009This Image shows type-safe method of defining the Actionlinks ,how to define it in VB.NET
View 1 RepliesThis Image shows type-safe method of defining the Actionlinks ,how to define it in VB.NET
View 1 Replieswhen i do this, i get the ACTION being called TWICE, what should i do about this?
if i call html.partial instead to just render the control, then i need to specify all the objects/values manually, which i shouldn't need to do this as the ACTION itself takes care of this stuff.
i maeks sense to have both these work together but they don't, what should i do?
How do I modify or create my own Html.ActionLink helper to accept and handle the first parameter (linkText) passed in as an empty string / nothing?Details: I currently have a strongly typed view that's passed a model which contains search results. My view loops through each item in the model and attempts to display a link to a contact with the following code:
@Html.ActionLink(currentItem.ContactName, "contact", "details", New With { .id = currentItem.ContactID }, Nothing)
Normally this would work just fine, but not every item in my search result has a ContactName. The Html.ActionLink helper errors when this first parameter is empty. In case it helps, here's the model property for ContactName (which is generated from a template due to Database First, so I don't believe it can be modified):
Public Property ContactName As String
I'd like to have a helper function that simply returns nothing if the ContactName is an empty string / nothing.I'm guessing I need to extend this helper, and I've struggled to find any good, up-to-date resources in VB.net for extending helper functions. Other approaches are more than welcome if they're considered best practice. I'm working in VB.net, MVC3, and Razor in the ASP.net 4.0 framework.
Basically, i don't want to use <input type="submit"> mainly because it's a button, i'd rather user ActionLink, so i am using Ajax.ActionLink, and i'm not sure what to place in the routeValues argument for it to pickup the new (edited) data (user enters comments etc) and send it to my action.this is what i have, but of course, it sends the original comment before user edit back to the server/action :)
<%= Ajax.ActionLink("Update", "UpdateComment", Model.Comment,
New AjaxOptions With
{.UpdateTargetId = Model.CommentDivId, .HttpMethod = "Post"})%>
ps: i know how to do this in javascript, and doing ajax posts etc,
This image shows how to define the RouteTable in C#, using the Route Class. How to define it in VB.NET?
View 1 RepliesI want to define several constants of pens like SystemPens. How do I do that?
View 6 RepliesI am using System.Reflection to load a type that I cannot otherwise load during design time. I need to pull all controls within a collection of this type, however, i the OfType command doesn't seem to like the reflection Syntax. here is "close to" what I got.
Dim ControlType As Type = System.Reflection.Assembly.GetAssembly( _
GetType(MyAssembly.MyControl)) _
.GetType("MyAssembly.MyUnexposedControl")
Dim Matches as List(Of Control) = MyBaseControl.Controls.OfType(Of ControlType)
So that code is bogus, it doesn't work, but you get the idea of what I am trying to do. So is there a way to use reflection and get all of the controls that are of that type?
i wonder if it's possible to define a variable/property of more than one type. Let's say i want a property TextWebControl that is a WebControl and also implements Web.UI.ITextControl(f.e. like a TextBox or Label). But i don't want to enforce that it is a TextBox or Label, but only one that inherits from WebControl and also implements ITextControl so that it also would work with controls added in future releases of .Net-Framework.
.Net-Framework 4.0
Edit: I have retagged the question and added VB.Net because it's my default language. Normally it's no problem for me to understand C# also, but i must admit that it's difficult to translate generic stuff to VB.Net without experiences and it's also better documentated in C# than in VB. So i would appreciate(and aceept) a working example of a VB.net generic type of ITextControl/WebControl.From Marc's answer i understand that i need a generic class. But how do i instantiate it in SomeClass? This won't compile:
Class SomeClass
Public Property info As InfoControl(Of WebControl, ITextControl)
End Class
Public Class InfoControl(Of T As {WebControl, ITextControl})
End Class
Is there any way to define a Generic in VB.NET which will accept only Singles or Doubles? I tried the following things, based on what I've found online, but none compile:
Dim target As Nullable(Of {Single, Double})
Dim target As Nullable(Of T As {Single, Double})
Dim target As Nullable(Of T {Single, Double})
Dim target As Nullable(Of Single, Double)
Dim target As Nullable(Of T As Single, Double)
I want to specify that target can either be a Single? or a Double? only.
I have a class called "heater". One of the properties is "designstatus", a string. I want to limit the property to one of three choices; "current", "obsolete", "notdesigned".
View 2 RepliesI want to know when I need to define a property in programming in general?,in every language
View 4 RepliesI have a list(of object) lets say ob1,ob2,ob3 that are classes I want to write a linq-querry that exstract from this list only one particolur object that is different time to time how can I write the linq querry?
dim List as new list(of Object)
list.add(ob1)
list.add(ob2)
list.add(ob3)
dim Result=(from P as ob3.gettype in list select p).tolist
but it does not work?
How to define array in vb2005? (Actually, I am making a game, whcih have to find out a pair of same pictures. I want to randomize 8 pictures, but it will randomize some pictures which is the same. Therefore, I need to use array.
View 3 Repliesbit is use for boolean where it is use to define result either 1 or 0 / true or false.
how to set it, if i want to define result either in or out/ yes or no/ big or small..
can i change it??what is the code to set it..
I need to do something like this Class A End Class Class B Inherit A End Class A=B If i try i get an exception! that i can not cast B in A. How can I overcome this problem? I need to define 2 classes B identical to A but as a distinct class What I need is to be able to cast one class to the other like A=B or B=A I tried with directcast but i got the exception what can I do
View 1 RepliesI know to define integer type sqlparameter but I do not know the decimal type sqlparameter for the precession.
I am giving a sample example.
//Code
Dim sqlparameters(2) as sqlparameter
sqlparameters(0)=new sqlparameter ("@RMID", SqlDbtype.integer,7)
but in case of decimal I am giving like this
sqlparameters(1)=new sqlparameter ("@RMID", SqlDbtype.decimal,7,2)
which is wrong
I have no idea as to how I can define a variable as "GLOBAL" in VB Express 2008. I used VB V 3.0 and if I remember correctly the statement "Global varName as Integer" allowed me to use the variable across different forms. I've tried the statement "Public varName as Integer = 0" on Form1 but Form2 tells me the variable is not declared.
The statement (in Form1) "Form2.Label1.Text = CStr(varName)" displays the value on Form2 in Label1 but I cannot then use the value again in Form2, e.g. "Label2.Text = Label1.Text". How I can transfer a variable value from one form to another and manipulate that variable in the second form?
[Code]...
I have remplace the keyarr definition by my SQL query: With the code above, I can print both keyarr in a console. What should I change in the _sqlReader.Read() function in order to get keyarr definition like the first code. I would like that keyarr could be
interpreted by the rest of my code.
I need to define Virtual IP programmatically (Perl or VB or CMD or java).I need it for temporary use, I can't use any actual IP address and I don't care if it will be accessible only from local machine.
View 1 RepliesI'm using the Hashtable class for the first time, and have a question about it:Is it possible to define a type for all it's elements? So that when you for example only put strings in it, you can retrieve them without having to cast them from objects.
View 7 RepliesWhat is that 0x thingy notation ALso what is &H notation Sometimes I see 0& when calling API what does that mean?What's the difference between 0& and 0
View 3 RepliesI am making an interface that has a number of events defined in it. When I implement the interface in a class the events will show up. I want to force a class that implements my interface to also have to make the event handlers too. I don't care where the class raises the event, but I want them to have to define what happens once the event is raised. Is this possible and if so, how do I do it?
View 1 RepliesIn java I use the Desktop application as under;Create JFrame Add JdesktopPane and in the Jframe constructor intilize the all the child forms and then in the events i use child form.visible method.But in the VB where is best technoque to use child forms to initilize?i also need a piece of code for the application to learn how effectively i use the VB to develop MDI application.
View 1 RepliesI have the following situation, can anybody help me in that?Following is a "pseudo" code of what I want to do in VB using VB.NET 2005:
[Code]...
I often have a class defined and I also define another class that is simply a collection of the other class. To do this I found it easiest just to define the other class as Inherits List(Of Type). The reason I define a collection class is to add extra functionality to the collection. Take the following code for example.
Class Car
Property Name As String
Property Year As Short
[Code]....
how can I define my own collection so that I can reference it by index or name like that. Right now I can only reference it by index.
Can we define a constructor with 'Friend' modifier?
Friend Class Reader
Friend Sub New()
End Sub
End Class
I'm trying to recreated some Excel code and an struggling with defining data types for use in Arrays.
Excel Code
Type Bags
feed_Bags As Long
drop_Bags As Long
level3_Bags As Long
mcs_Bags As Long
[code]....
How can I re-created this in VBA
Im trying to grasp session varibles, i understand what they are etc but i would like to know how to define a type for each session variable.Iv written it like this
Session("Title") = txtTitleContent.Text
How can i tell it what type of value is going to be in it, because at the moment im only playing about with strings, but what if i have an integer and want to pass it back to the back end to save it will throw an error saying "conversion from string to integer is not valid" should i use Cint to deal with this?
I want to define a variable that is a collection of interfaces - it could be any interface that is defined for use in my app.
e.g. Dim x as New List(Of InterfaceBase)
Is there a base type for all interfaces that I can use for InterfaceBase?
I am having a structure that is actually a simple byte with more functionality.[code]...
If there would be a way to inherit from Structure I would simply inherit from Byte adding my functionality, basically I just need a byte Structure with custom functionality.
My question is also valid when you want to define your new singleton member value-types (like, you want to define a nibble-type for instance etc.) and you want to be able to set it with an assignment to number or other language typed representation.