MVC :: Passing Int Value From RedirectToAction Method?

Nov 15, 2010

I want to pass a int value using RedirectToAction() method .

Here i have a Action method Index() which takes 1 parameter id in most of the cases this id cannot be null.

When i submit the form using Action method Edit(), i want to come again on Index page,so i am using method RedirectToAction("Index")

but here with Action Name i want to pass the id also. How can i do it?

View 3 Replies


Similar Messages:

Passing A Controller As A Parameter - Can't Get To RedirectToAction Method

Jun 15, 2010

My method looks like:

public static RedirectToResult(Controller controller, ...)
{
}

when I do:

controller.

I don't see RedirectToAction, how come?

I get RedirectToAction from within the controller's action, but not when I pass the controller as a parameter to another classes method.

View 3 Replies

MVC :: Return RedirectToAction() Passing Object?

Apr 9, 2010

I have the following ActionResult() method:

[Code]....

The method is called once the <form> is submitted. If the validation is good, it moves on to create a new user Once the new user is created, I want to redirect the user to a "ThankYou" page passing along the newly created user (object). The TempData["User"] trick seems to work like a charm! Then inside my ThankYou ActionResult() I do the following:

[Code]....

The problem I have is once the user has been redirected to the "ThankYou" page. If he decides to refresh (F5) his browser, the value in the TempData is lost.

What are my possibilities to overcome this issue?

Instead of passing an entire object to my "ThankYou" page, I initially thought of passing the ID of the newly created user and re-query my database to get the object.

The only problem is that the ID will be seen in the QueryString allowing the user to simply change the ID value and try to find other users...

Is my only other alternative to simply place the user object inside a Session? Is that my only other option?

View 6 Replies

Forms Data Controls :: DetailsView Delete Method Passing Null Values To Objectdatasource Underlying Object Delete Method

Apr 12, 2010

I am using VS 2008 SP1. My also have included CSS Friendly adapter [URL] in my project ( I mentioned this because my GridView Empty data template is not showing when using GridView's CCS Friendly adapter). I have a GridView and a DetailsView. When a record in GridView is selected its details information is shown in the Details View. Type of Data source I am using is ObjectDataSource. My Insert and Update methods works perfectly. It is only the Delete method that is passing null values to the underlying object delete method. My source codes for both the UI, BLL, DAL is shown below

[Code]....

My Business Object code is below :

[Code]....

My Data Access Layer Code is:

[Code]....

View 2 Replies

C# - Passing A 'var' Into Another Method?

Mar 28, 2010

I am probably totally missing the point here but....

How can I pass a 'var' into another method?

(I am using linq to load XML into an Enumerable list of objects).

I have differernt object types (with different fields), but the final step of my process is the same regardless of which object is being used.

XNamespace xmlns = ScehmaName;
var result = from e in XElement.Load(XMLDocumentLocation).Elements(xmlns + ElementName)
select new Object1
{
Field1 = (string)e.Element(xmlns + "field1"),
Field2 = (string)e.Element(xmlns + "field2")
};
var result2 = Enumerable.Distinct(result);

This code will vary for the different type of XML files that will be processed. But I then want to iterate though the code to check for various issues:

foreach (var w in result2)
{
if (w.CheckIT())
{
//do something
}
}

What I would love is the final step to be in a method in the base class, and I can pass the 'var' varible into it from each child class.

View 3 Replies

Passing A Parameter To Action Method?

Sep 8, 2010

public ActionResult RenderMyThing(IList<String> strings)
{
return View("RenderMyView");
}

How do I pass in strings?

routes.MapRoute("MyRoute", "RenderMyThing.aspx", new { controller = "My", action = "RenderMyThing" });

Is there a way I could pass in strings here?

Secondly, how does ASP.NET MVC know that action is my action, and controller is my controller. Like I saw this in samples, and it does work, but isn't it just an anonymous object with no type?

View 1 Replies

MVC :: Passing Model From One Action Method To Another

May 23, 2010

I'm sure something like this worked before for taking a type and pass it to another action method (I cannot / never use TempData)

[Code

View 6 Replies

Passing Multidementional Array As Paramater In Method?

Sep 10, 2010

i want to pass multidementional array as parameter, below the code i worked, is it right

class ASRateContract
{
public string[,] standardrate = new string[3,2];
public string[,] storagerate = new string[3,3];
public void setstandardrate( string [3,2]name )
{
standardrate = name;
}
public string setstoragerate()
{
return "";
}
public string getstandardrate()
{
return standardrate;
}

View 6 Replies

Passing A JavaScript Variable To A Helper Method?

Feb 24, 2011

I am using ASP.NET MVC 3 and the YUI library.I created my own helper method to redirect to an edit view by passing in the item's ID from the Model as such:

window.location = '@Url.RouteUrl(Url.NewsEdit(@Model.NewsId))';

Now I am busy populating my YUI data table and would like to call my helper method like above, not sure if it is possible because I get the item's ID by JavaScript like:

var formatActionLinks = function (oCell, oRecord, oColumn, oData) {
var newsId = oRecord.getData('NewsId');
oCell.innerHTML = '<a href="/News/Edit/' + newsId + '">Edit</a>';
};

View 1 Replies

Passing Value From Action Method To View From Where It Is Called

Mar 3, 2011

In one view (view1) there is a text box and a button beside it. i click on that button, i am popping another view (Create view) as a seperate window. in create view i am entering some values and creating a record in db. out of these values one value i have to send back to "View1". how can i send this value? i am opening view2 from view1 like

<input type="button" value="Get ID"
onclick="window.open('<%=Url.Action("Create","Controller1") %>',
'','scrollbars=yes,width=800,height=800,resizable=yes');"
/>

View2 contains some fields like Name,Email etc... and I click "Create" to call HTTPPOST. there i add the values to db including a generated guid. i want to send this ID to view1.

View 2 Replies

WCF / ASMX :: Passing Multiple Parameters To A Web Method?

Dec 15, 2010

I am creating a Web Service, which will be used by a client to send data to our Database.The client will be sending close to 30 fields that will be updated to our table. If I write a Web method, I will need to have all these 30 fields as parameters to that method. Is there a better way than sending all of them as parameters?

View 3 Replies

WCF / ASMX :: Passing Parameters To Webservice Method?

Nov 13, 2010

i have the following method, however i want to pass methods to it, i know how to do it the usual way, however when it comes to Webservices/API's what is the correct way to do it. Here is my method so far;

[Code]....

View 1 Replies

C# - Passing The Values Of Form Controls To .NET Page Method

Mar 2, 2011

I have this function:

[System.Web.Services.WebMethod]
public static string EditPage(string nodeID)[code]....

in my Web Form but When I try to reference their IDs they don't auto complete and can't be found.

View 2 Replies

Asp.net - Passing Button Control To Http Post Method

Mar 29, 2011

I have a actionresult index method in my controller and a http post method for the same name. when i run the program the control should go to the http post method but by default it goes to the index method.

[code]...

View 1 Replies

WCF / ASMX :: Passing A Web Service To A Method In Class Library?

Mar 23, 2011

I have a web service called service1. Is it possible to pass the parameter related to the service to a class library so for e.g.

Service1.service ws = new Service1.service();
Service1.UserDetails ud = null;

now if I call a method that exists in a class and pass ud. Cam i do that because I am trying to do this and I am getting an error. Do i need to add a web

reference to this service in the class library My method call is like this

authenticateUser.Authenticate(ud, UserName);

and in the class libary I have

public void Authenticate( Service1.UserDetails ud , string UserName)
{
}

View 3 Replies

Forms Data Controls :: Passing DataRow To Method From Template?

Jan 21, 2011

I am using a template file for the ItemTemplate of the repeater control.

Within the template I am trying to get the value from the current datarow.

The code was then converted from VB to C# and I am getting the following error:

'System.Web.UI.Control' does not contain a definition for 'DataItem'

Below are the C# and VB versions:

[Code]....

Converted C#:

In .ascx...

<%#GetAssociationName((RepeaterItem)Container.DataItem)%>

In .ascx.cs...

Then get the value using the following method.

[Code]....

View 1 Replies

Web Forms :: Passing A Button's Click Event To A OnPreRender Method?

Mar 2, 2010

I'm attempting to use a Button's OnCommand method to handle it's click event so that the event is passed on to OnPreRender method as shown below. So basically the OnPreRender method is called upon a button click. I'm need to use the OnCommand method because I have 2 buttons.

//mark up
<asp:DataPager ID="GroupSearchResultPager" runat="server" OnPreRender="groupSearch_PreRender" >
<asp:Button ID="btnSearchUser" runat="server" Text="Search" OnClick="btnSearchUser_Click" CommandName="searchUser" />
//code behind
protected void btnSearchGroup_Click(object sender, CommandEventArgs e)
{
groupSearch_PreRender(this, e); //call groupSearch_PreRender
}
protected void groupSearchView_PreRender(object sender, CommandEventArgs e)
{
if(e.CommandName=="searchUser")
{
do stuff
}
}

However, this results in the following exception:

CS0123: No overload for 'groupSearch_PreRender' matches delegate 'System.EventHandler' So basically groupSearch_PreRender only takes an EventArg. I've tried casting as shown below but it doesn't seem to work. How else can I pass the button click event to the PreRender method?

protected void groupSearchView_PreRender(object sender, EventArgs e)
{
CommandEventArg entry = (CommandEventArg)e; //casting to CommandEventArg
if(entry.CommandName=="searchUser")
{
do stuff
}
}

View 1 Replies

Forms Data Controls :: Passing Container.dataitem As Method Parameter?

Apr 26, 2010

input type=..... value="<%= ISO3166CountryList.GetCountryByCode("IE", CurrentLocale).Name %>" />

I'm looking to replace the hardcoded IE with something like

<%#(Container.DataItem as PhoneNumber).ISO%>

No variations of what I've tried worked. How can I get a databinded value when within a <%= code block? Do I need to use an intermediary variable?

View 2 Replies

MVC :: Radio Button Sets From The Controller Without Passing 15 Different Variables To The Post Method ?

Aug 27, 2010

I'm fairly new to MVC and admittedly don't fully understand how data is passed between Views and Controllers. That said, here is my issue.

I am working with C#. I have a page which has a list of items. Each item has a radio button set of three associated with it and there are 15 of these sets on the page. Thus I have radio1, radio2....radio15, etc. Each of these has value 0, 1, or 2 upon submit. I can't seem to understand how to get the information out of these radio button sets from the controller without passing 15 different variables to the post method in the controller which is associated with the view; ie passing Int32 radio1, Int32
radio2,.., Int32 radio15, etc.

I tried using ViewData["radio"+i] in a loop to access the value of each radio button set, but this, apparently can only be used to pass data to the View from the Controller and not the other way around.

View 6 Replies

Security :: Passing Custom Create Date Using Membership CreateDate() Method?

May 11, 2010

I want to pass create date in Membership CreateUser(..., ..., ...) method. As It's only providing no such method of passing custom create date of an user(s). Is there a way to pass it? I'm using .NET Framework 2.0. If there is no such way then have any idea my Microsoft is not providing this functionality for passing custom value(s) as store procedure is implemented all the table parameter(s).

View 1 Replies

RedirectToAction Usage In Asp.net Mvc

Dec 6, 2010

i want to make some questions about asp.net MVC,actually,i am not familiar with web developing.

But,i am assigned for web part.we are using like this.first,we create get set
properties for person data

public class Person
{
public int personID {get;set;}
public string personName {get;set;}
public string nric {get;set;}
}

and then after login,we put data in that class and we use RedirectToAction method like this,

return RedirectToAction("profile","person",new { personID = Person.personID});

it's working normally,but,parameter are shown at URL,how i hide them and also can i hide action name?

View 2 Replies

MVC :: Using ModelState With RedirectToAction?

May 18, 2010

I have created a custom validation attribute for a class. The validation is actually against one property of the class, but since it needs to be compared to another property of the class at runtime, I had to pull in everything from the input form, perform the validation and output the errors. This being the case, I manually added a ModelError to ModelState if the ModelStats.IsValid returned false. I have another thread that goes into this, as I still haven't been able to make the client-side validation work for the custom validation (built-in validation runs client-side without a problem).

Here's the issue: I want to use the Post/Redirect/Get pattern to avoid issues where users refresh their page and cause another post of the form data. If I complete my Controller action and return a View after assigning an error with ModelState.AddModelError, I get the user feedback with the red input field and error message shown. However, just returning a View like this makes you vulnerable to the repeated posts issue. I want to use RedirectToAction to perform a get and avoid this problem, but when I do that I no longer have the ModelState error feedback on my rendered View. Here're the calls I'm making:

[Code]....

I'd like to be able to redirect to a get action and retain the ModelState.

View 2 Replies

Is There A Strongly Typed RedirectToAction In MVC 2

Oct 2, 2010

I wish to do something like this:

return RedirectToAction<SomeController>(c => Index(someparameter));

How to do this ?

View 2 Replies

Use Custom Route With RedirectToAction (asp.net Mvc)

Mar 8, 2011

I use the RedirectToAction with parameters in my action method

return RedirectToAction("ListThreads", "View", new { category = "1", subcategory = "49"});
After redirect the url comes out like this
http://domain/Forum/View/ListThreads?category=1&subcategory=49
I want it to be generated like
http://domain/Forum/View/ListThreads/1/49

How to do it?

Note : I already have a route in global.asax that is used by all the pages/links.

context.MapRoute(
"Forum_subcategory",
"Forum/{controller}/{action}/{category}/{subcategory}",
new { controller = "View", action = "ListThreads", category = "", subcategory = "" }
);

View 1 Replies

MVC :: RedirectToAction And Instance Of Class?7

Jan 27, 2010

I've a class that hold all the necessary properties. I want to pass the instance of that class in RedirectToAction. Right now, I can pass the instance but the action to which it redirect, doesn't receive that same instance. The target action has new instance of class.

eg.
AbcFilter a = new AbcFilter();
a.ABCname="abc";
RedirectToAction("AbcAction",a);
Public ActionResult AbcAction(AbcFilter a)
{// this method receives the "a" as new instance, but not the same that I pass in RedirectToAction
}

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved