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

Top 5 Contributors of the Month
Post New Web Links

Pass textbox value to controller class

Posted By:      Posted Date: October 08, 2010    Points: 0   Category :ASP.Net

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 

View Complete Post

More Related Resource Links

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


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

Pass values From Html.BeginForm To Controller

I'm using 2 submit buttons. <form id="form1" runat="server"> First name :<asp:TextBox ID="FNanme" runat="server" /><br /> Last name :<asp:TextBox ID="LName" runat="server" /><br /> </form> <% Html.BeginForm("ActionName", "ControllerClass", FormMethod.Post); %> <input type="submit" name="submitButton" onclick=" return popUp1Msg()" value="Reject" /> <input type="submit" name="submitButton" onclick=" return popUp2Msg()" value="Accept" /> <% Html.EndForm ( ); %> On every submit, Popup appears with Ok and Cancel buttons.When user select Ok. How can I pass FName and LName values to controller? Thanks  

pass value from class to

Hi,I have my class "GeneratMenu" i need to direct pass the value from this calls to asp.net page which have <div id=dmenu runat=server></div>i tried in codebehin of that priticular asp page with this.dmenu.innerHtml = "Test" and it work well. But when i am using under my class like. the error comes : divmenu' is not a member of 'MyProject.MyClass'Please suggest me where is the wrong in my code?Public Class MyClass Inherits System.Web.UI.Page Public Sub createMenu() Dim xfile As String = GetXML("menu") me.dmenu.InnerHtml = xfile End SubError 2 'divmenu' is not a member of 'AccountOpening.MainCLS'. D:\Users\Nada\Desktop\BarwaBank\AccountOpening\AccountOpening\AccountOpening\Class\Main.vb 22 9 Account

Creating class in controller

I am using vs 2010, mvc, linq to sqlMy Model is .dbml filetbl_teacher,tbl_class,tbl_subject etc are involvedI write code in my controller for table join.public ActionResult Index() { var DataContext = new SMSAPPDataContext(); var result= from t in DataContext.tbl_teachers from e in DataContext.tbl_teacherenrollments from b in DataContext.tbl_batches from c in DataContext.tbl_classes from s in DataContext.tbl_subjects where t.Teacher_ID == e.Teacher_ID && e.Batch_ID == b.Batch_ID && b.Class_ID == c.Class_ID && e.Sub_ID == s.Sub_ID && t.Teacher_Name == "ABC" select t; return View(result.ToList()); I am passing Teacher Name in query and want to get result from two tables , from class & Subject.But, When i create view i can only select one table i.e. tbl_classNow i decided to create a class in controller. I Want to call both my tables in here. A new Model Classnamed MyViewModel will be  created, and I will pass this mod

Pass an Event handler to an helper class

I have a static class (an helper class) which has the responsability to create control and add them to a panel passed by parameter, this method is used by a lot of  user control. My problem is to create a linkbutton and define the click event handler which is not in the static class but is defined in the class which call this method. Following you find the exampleI have a static class (an helper class) which has the responsability to create control and add them to a panel passed by parameter, this method is used by a lot of user control.My problem is to create a linkbutton and define the click event handler which is not in the static class but is defined in the class which call this method.Following you find the example:public static class myHelper { public static AddControlToPanel(Panel p) { LinkButton l = new LinkButton(); l.Text = "Click"; l.CommandArgument = "click"; l.Click += Manage_CLick //Manage_Click is a method of the "caller" class p.controls.add(l); } } public class MyuserControl() { public void InitializePanel() { Panel mainPanel = new Panel(); myHelper.AddControlToPanel(mainPanel) } public void Manage_Click(object sender, EventArgs e) { //Do something } }How can I pass the handler to the static class? I have to use delegate? how?Best regards--Andrea

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>


how to pass asp:DropDownList value to controller


In my ASP MVC app I have an asp: DropDownList control that has a source of a Linq data class.  The values in the list are getting set fine, but when I select one, and then click on an Html.ActionLink, and pass control back to my controller, I'm not sure how to fetch the value that was selected from the DropDownList.

Any suggestion are appreciated.

How to Pass data(not the part of model) from View to Controller?


How Can I Pass data(not the part of model) to Controller from View?
View Code

<%= Html.ActionLink(item.Name, "ActionName", "ControllerName", new { companyID = Html.Encode("abc"), ID = Html.Encode("xyz") })%>

Controller Code

public ActionResult ActionName(string companyID , string ID)

Any idea?

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

Unable to pass parameter to a buisness class


YOur feedback would be appreciated...

I am getting this error 

Must declare the scalar variable "@InvoiceNumber".

in the following code, although i declared InvoiceNumber as a parameter in the Datasource object.

public class GetDetails
    public static DataSet Details(string InvoiceNumber)
        SqlConnection con = new   SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        string sel = "Select InvoiceNumber,CustEmail, OrderDate,Subtotal"
               + " from [Invoices]"
               + " Where InvoiceNumber = @InvoiceNumber";
        SqlCommand cmd = new SqlCommand(sel, con);
        // Add the parameters for the SelectCommand.
       cmd.Parameters.AddWithValue("InvoiceNumber", InvoiceNumber);

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).

How to Pass integer value back from get and set class



I am trying to set a integer value in a class from license information, and then get that value passed back to my Program.cs class (e.g. of value 10).

However when I try to return the value to another part of the class (as below) it says 'Cannot implicitly convert type to Manco.Licensing.License'. Also any idea how do I call this class to get this integer value back to Program.cs ie should this be LCheck.Value.days? In this class daysleft is a integer value.

using System;

public class LCheck
private Manco.Licensing.License m_License;
public static int daysleft;
public static int days;

public int Value

int days = daysleft;
return days;


public Manco.Licensing.License License
m_License = value;
daysleft = Convert.ToInt32(m_License.DaysLeft.TotalDays);

return daysleft;



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.

Class Diagrams

Class diagrams show the static structure of the systems. Classes define the properties of the objects which belong to them. These include:

Attributes - (second container) the data properties of the classes including type, default value and constraints.
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