.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

pass value from textbox to action, formcollection best way here?

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

Hi I'm building a e-commerce store and on quantity of product I'm going with a textbox. I thought I would ask how would you do this? a viewmodel to use a strongly typed textbox or just get the value of the textbox from the formscollection passed in to the action?

Thanks for any input

View Complete Post

More Related Resource Links

Somehow to pass a value to a action without having it on display in url?


Hi. I really cant figure this out but so I thought I would ask you. My scenario is I'm listing customers with paging. Lets say Im on page 4 and I choose to edit a customer. What I want to do is to be able to return to that page 4 when Im done editing the customer. How should I approach this?

Form Action Button to pass parameters through URL and how to fill a NewForm with them

Hi I'm trying to solve a bigger problem we have in babysteps, and I guess after days of searching and trying I simply need to ask for help. The big picture is, that we're trying to put a Form Action Button (via Sharepoint Designer 2007) above a custom DataForm DispForm.aspx which is supposed to navigate to a NewForm.aspx where the Title Field is supposed to be prefilled with a parameter from the DispForm and the user should be able to add information to the item before it is saved. I found several explanations from people on the internet, but nothing really worked. The first babystep would be to get the parameter through the button into the url of the new item.   < input type = "button" value = "Zugriff Beantragen" name = "btnFormAction0" onclick = "javascript: {ddwrt:GenFireServerEvent('__redirect={../Zugriff Beantragen 2/NewForm2.aspx?test={ItemID}')}" />   That's the code for my button. Somebody wrote that should definitely work because SharePoint is able to replace {ItemID} with the actual ID of the item. Well.... it kind of doesn't. What I get as the end of the new URL is exactly "...?test={ItemID}"   I tried with different names for the ID, I added an @ before those ... no change. I read somewhere about javascript.functionName() which should work with all parameters of the item, but

How can i route to different actions having same signature if i don't want to pass action name in U

I am having one controller Test having following actions (1)public ActionResult ABC (string parameter1, string parameter2)       (2)public ActionResult XYZ (string parameter1, string parameter2,string parameter3, string parameter4)       i have added following html.routelinks  <%= Html.RouteLink("ABC","ABC", new { parameter1 = 100, parameter2 = 200 } )%><br /> <%= Html.RouteLink("XYZ", "XYZ", new { parameter1 = 1000 , parameter2 = 2000 }) %> last two parameters in XYZ action are optionals so i have not passed them in Html.routelink  routes.MapRoute("ABC", "Test/{parameter1}/{parameter2}", new { controller = "Test", action = "ABC", parameter1= 0,parameter2=0 }); routes.MapRoute("XYZ", "Test/{parameter1}/{parameter2}/{parameter3}/{parameter4}", new { controller = "Test", action = "XYZ", parameter1=0,parameter2=0 ,parameter3=UrlParameter.Optional,parameter4=UrlParameter.Optional}); In above senario in both cases same route "ABC" is called eventhough i have clicked on second Html.routelink.can anyone solve this issue ? how can i route according to route name instead of number of parameters?

Is it possible to pass textbox value as a parameter through hyperlink? Thanks

Is it possible to pass textbox value as a parameter through hyperlink, with the press of a button or without? Thanks
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
       <br />
        <br />
        <br />
        <asp:Button ID="Button1" runat="server" Text="Button" />

        <asp:HyperLink ID="HyperLink4" runat="server" 
        NavigateUrl="~/ASPInvoiceGrid.aspx?PONumber={0}" Target="_blank">Invoice Details</asp:HyperLink>


Pass textbox value to controller class


Hi All

How to pass the textbox value to my controller there is no form and post method in the view

I have taken one input type textbox which is not bind with my model.

I need to access that value to controller

Please give me a solution 

How do I - pass multiple params from multi-select drop down on one report to another via action


Report 1 - 3 params:  @Status =Y,N  @FromDate, @ToDate.  Report one shows 2 cols (Status, Total). 

 @Status gets values from shared dataset - getStatus

Status      Totals
[Status]    [Total]

I created an action [Total] when clicked runs another report that accepts the same 3 params (Status, FromDate, ToDate) and works fine if i only select one of the status' from the status param drop down.

I am trying to create an action on [sum(Total)] that will run the same 2nd report with both status' selected.  Show it should show me details of all Y and N

The second report will work if i set the 2nd report @Status param to no default value.  But i want a user to be able to run the 2nd report by itself if needed so i set the @Status param to Get Values from a Query, which get the same dataset as report 1 which is getStatus.  It will not populate the 2nd report Status field when I do this.  I am forced to set it to no default values.  Is there a way to pass both the Y and N from report 1 to report 2 and still keep the drop down multi-select box on report 2 for Status?


FormCollection collection not being passed to controler action


 What would cause the  formsCollection now to be passed to the controler? i have to be missing something.









foreach (var item in Model.CartItems)"ChangeQtyCart"

How can we Pass a textbox value to next webpage in asp.net C#


 I have some vales in my web page which i want to pass into my next pasge for further work

please help me to find out a good method to pass my textbox values to next opening window


Thank you

Rupesh B S

How to Pass Grid Row to Textbox on Modal Popup?



I have a panel with a textbox on it.  In the GridView I have a button in a template.  I can send the row data from the button's OnClick to the text box easily enough. 

                <asp:TemplateField ShowHeader="False">
                        <asp:Button ID="Preview_btn" runat="server" CausesValidation="false" 
                        Text="Preview" OnClick="GoToPreviewPage"/>

 Protected Sub GoToPreviewPage(ByVal sender As Object, ByVal e As EventArgs)

        Dim row As GridViewRow = DirectCast(TryCast(sender, Control).NamingContainer, GridViewRow)
        Dim myRowIndex As Integer = row.RowIndex

        Textbox2.Text = Gridview1.Rows(myRowIndex).Cells(1).Text

End Sub

When I added the ModalPopupExtender to the button and pointed it to the panel, now the button's OnClick event and OnClientClick and CommandName no longer fire.  The Popup works fine, I'd just like to be able to pass the RowID to i

How Can a pass textbox value to my "src" Area


Hello Brother

i have a doubt

i received a request.querystring() value from another form and a i stored it in a textbox. when i try to add the value of that text box to src area it didn't work

i assigned src like following


and when i am giving 

Src="music\abc.mp3" - it will work

if i am soring it in a textbox and try to add it SRC area nothing will work

How to pass parameter in sharepoint form action "Navigate to page"

I'm new to MOSS 2007, currently working on the SharePoint form.
In the NewForm.aspx page, once user entered all the fields and click on the "save" button, the data will be save into the list and also i tried to redirect it to other page.

I read few articles on this issue, most of it is about redirect to same directory but different page. Example: Allform.aspx, Display.aspx or editform.aspx.

I wanted to redirect to different path page.
javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={http://server/test/myForm.aspx}')}". This line works when i click on the "save" button.

Assume i wanted to pass a title parameter to directed page.
javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={http://server/test/myForm.aspx?PageTitle_x003D__x007B_@Title_x007D_}')}  <=== this line not working, what i get from the directed page by using querystring is "{@Title}". 

How can i pass the parameter to directed page and read the value?

Anyone can help me on this?


Can't sort dataset and can't pass dataset to a textbox's click event handler. Please give me some


I have written VB code that fills a dataset from an external database. The dataset, or I suppose more correctly the datatable within the dataset, is bound to a PathListBox.ItemsSource property which is displaying fields from 5 records.

Now I need to sort the data within the dataset when the TextChanged event is fired on a text box used for "searching". The problems that I am having are that a dataset cannot be sorted (I think I have found a solution for this) and I cannot pass a dataset to the TextChanged event handler.

Obviously I am not experienced with this and I have been pouring through several books to no avail. This seems like something that should be relatively simple and I am probably over complicating it.

Would someone please offer me some suggestions (and no rtfm please... I've been doing that so much that my eyes feel like they are scraping across my keyboard).

Pass multiple values to an array parameter of an action


Hello guys,

ca anyone tell me how to get an url Like http://localhost/xxx/ControlerName/ActionName/2,3,4

to map to an Action having an int[] parameter?

For example to a Action with Signature:

1    public ActionResult Index(int[] ids)
2    {
4    }



1    public ActionResult Index(List<int> id)
2    {
4    }

I couldn't find any logic for doing this. So I've implemented an ActionFilterAttribute, but I would prefer to use an built in logic.
But if there's no built in logic, feel free to use my logic:



1    [ArrayOrListParameterAttribute("ids", ",")]
2    public ActionResult Index(List<int> ids)
3    {
5    }
7    [ArrayOrListParameterAttribute("ids", ","

Textbox Editable GridView in ASP.NET

This article describes how I made a fully editable gridview in C# using ASP.NET 2. The idea is that the GridView looks and works like an Excel spreadsheet. You see all the cells in the table, and you can edit any of the cells you like, and they are automatically updated (i.e. saved to the database). This is very often how people expect data tables to work in web pages, and I've often seen people clicking in vain on un-editable gridview cells, somehow expecting to edit them, and not understanding that they need to click an Edit button at the end of the row.

Highlighting Rows with TextBox OnFocus

In another article I explained that how you can make the rows of the GridView control clickable and highlight them when they are clicked. In this article I will explain that how you can highlight the GridView rows when you focus on the TextBox which is contained inside the GridView control.

Custom Editing Behavior for DataGridView TextBox Columns

For various reasons I'm using a DataGridView instead of a ListView, and while configuring the DataGridView to look like a ListView wasn't much of a problem, there's one thing that got on my nerves, which is the behavior of textbox cells in edit mode: It is much too easy to leave the edit mode accidentally, simply by pressing the cursor keys at the wrong time. For example when the text caret is positioned behind the last character of the textbox cell content, and you press the right arrow key

Editable Gridview with Textbox, CheckBox, Radio Button and DropDown List

This is an example of an editable gridview containing different ASP.NET controls. When user wants to edit values in gridview, she/he can use these controls to edit existing values in Gridview Edit Mode.

Using the Code
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend