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


Top 5 Contributors of the Month
david stephan
Santhakumar Munuswamy
Fauzul Azmi
Asad Ali
Post New Web Links

Calculate sum of textbox values

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :ASP.Net
 

Hi, I have about 12 sets of textboxes wherein lets say (for set 1), txt1 is the quantity, txt2 is the rate and txt3 is the supposed to be the total amount (txt1 * txt2). I need to calculate the total for all the 12 sets and hence writing individual javascript formulas is way too tedious and way too lengthy also.

I have been searching the net for a typical javascript formual which will calculate the total amount on "onblur" event of quantity textbox (txt1). I understand i have to pass the parameters to the function and also the function should return the total amount as a return value to the 3rd parameter passed as an argument to the function. Trying directly gives different errors on runtime. Gathered that i will have to use the ClientID, in which case i would have to hardcode formulas and parameters for all 12 sets.

Is there any way i can pass 3 parameters to a javascript function, 2 of which will be calculating fields (txt1 and txt2) while the 3rd will the resultant field. The formula should be such that the onblur event should be able to put the total amount in the 3rd field for each set.

Hope i have expressed the problem in a proper manner and would deeply appreciate a fully functional formula to the above.

 

Using VWD 2010 and SQL Server as the database.

Any help will be appreciated. Thanks

Tommy




View Complete Post


More Related Resource Links

how to bind Dropdownlist based on textbox values

  

hi

I have one drodownlist which show data based om textbox values...

Let us consider i have 

Select Name from table1 where Type IN(@typ)

here @typ is textbox values

here for example textbox will have some thing like this L1,L2,L3..

How to filter Name based and shown in drodownlist based on this L1,L2,L3(on textbox)..

Help me in this


Retain DropDown,TextBox's previously selected values after redirected from another page.

  

 Hi People, How are you all doing?

I have 2 pages one is SearchPage & It has DropDowns, textboxes to specify the search criteria. From the search result the user is redirected to another page when he clicks the hyperlink in the search result  where he fills in the information and again redirected to SearchPage. Now the SearchPage is posted back with no state i just want to retain the search criteria and display when user comes back. Please give me some suggestion how to get this done. I've used ViewState to save the values and check them in Page_Load but they are null.   

Thanks

Abid

 Update: I've come up with this code. But the problem is The values are being retained but the Button_Click event is not being handled properly. When i Check the code even after this "DropDownList1.SelectedValue = Session["Name"].ToString();" DownList1.SelectedValue is EMPTY"" samw with DropDownList2 . please Suggest something

 

    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsControlsEmpty())
        {
            if (SessionExist())
            {
                DropDownList1.SelectedValue = Session["Name"].ToString()

keep values in textbox in gridview whilst paging

  
Hi,   I have a gridview in my webpage which has paging enabled. There are around 5 textboxes in a row and when I enter some text and then move to another page and move back to the page I entered the values in, they are not lost. I have enabled the viewstate in the gridview. I have implemented a datatable to my grid which should hold the values in the viewstate. This worked before I added paging. Please can someone offer some advice as to how I can maintain the values in textboxes whilst moving between different pages? I have tried searching it but I can't seem to find any relevant info.   Thank you very much.

How do you calculate a value in one list from the conditional adding of values in another list ?

  
I have a list (call it my first list) with a attribute of Initial Estimate (Hours) and a unique ID and want to conditionally search for that unique ID on another list (second list) and aggregate the Initial Estimate (Hours) on the second list to arrive at single value for my first list! Any ideas on how to do this?

Custom Validator on DDL&Textbox values

  
I need to write a 2 custom validators that works as follows: I have a formview (Formview1) with an EditItemTemplate. The validators need to validate values in "DropDownList1" and a textbox called "EndUserGUIDTextBox" If the value in DDL1 is ("Assigned" or "Assigned to End User") and the value of EndUserGUIDTextBox is ("unassigned" or "pending" or NULL) then I need a validator to fire and return {"GUID must be assigned when status is" & DLL1 value}. If the value in DDL1 is ("In Stock" or "In Repair") and EndUserGUIDTextBox is NOT ("unassigned" or "pending" or NULL), then I need a validator to fire and return {"GUID must not be assigned when status is" & DLL1 Value}. The validators needs to run and show in the formview when the UpdateButton in my Formview is clicked. I'm doing this in VB. Real noobie here! All help appreciated. Thanks,

Validating Textbox for Numeric Values

  
I want to validate a textbox that only a numeric currency value can be put into it, for example 0.00. I thought the following code was correct but it doesnt seem to wrk, its causing an error on my page and when I remove it the page is fine, it doesn't actually give exact details of the error on the page just says "syntax error" in the browser that is all.<asp:CustomValidator runat="server" ErrorMessage="Please enter a numeric value for Night Rate in the format of 0.00" ID="NightRateNum" ControlToValidate="txtNightRate" Text="*" ClientValidationFunction="^\d+(\.\d\d)?$"></asp:CustomValidator>Would appreciate if any can tell me where I went wrong Thanks

Unable to change textbox values after manual assignment

  

Hello,


In my webapp, I have a DropDownList_OnSelectedIndexChanged that assigns values for a number of <asp:textbox'es depending on which entry is selected...

       public void ModifyProjectIDBox_SelectedIndexChanged(object sender, EventArgs e)

        {

            int tempJobID = Get_Selected_Report();

            dbCommandString = "SELECT Name, Address, State, Awarded, StartDate, EndDate, HomeLocal FROM dbo.ProjectInfo WHERE ProjID = " + tempJobID;

            dbComm.CommandText = dbCommandString;

            dbConn.Open();

            dbReader = dbComm.ExecuteReader();

            dbReader.Read();


                ModifyProjectNameBox.Text = dbReader[0].ToString();

           

            ModifyProjectAddrBox.Text = dbReader[1].ToString();

            ModifyProjectStateBox.Text = dbReader[2].ToString();

          

Using Rules to populate a textbox based on other values.

  

I am building a web-friendly form in Infopath (little new to the software)...

I have been able to hook up my form to my SharePoint and pull in user data so I can pre-populate various fields.

One field is not in our Profile services (nor Active Directory).  I'll call it Company Code.

But you can determine Company Code by checking the Company and Department.

Something like:

Company = "ABC", Department = "123" then Code = "XCV"
Company = "ABC", Department = "456" then Code = "VCX"

etc...

Since I am successful pulling the Company and Department from the Webservice.

I figured I build a text-box and put 30 or so rules on it to analyze the contents of Company and Department to determine what should be in the text-box.
So I used Conditions to check the Comany and Department and then the rule set the contents of the Company Code box.

However it seems as though the rules never run. 

And I got to thinking, when DOES the rule know when to run?  I don't see an "onchange" event or anything (trying to avoid code for web-friendly anyways) - so....

I do have the Company and Department fields populate immediately when the form is opened, but is that early enough for the rules?

Do the rules have to manually tri

perform sum of textbox values and display the total in gridview footer row textbox

  

i have a gridview in which i have added two textboxes .

the second textbox is placed in footer of gridview

wht i want is when the user enters values in the first textbox the total of these textboxes should be displayed in footer row.

Pls help


Adding Textbox values using javascript.

  

Hi All,


i am developing an application using ASP.NET with C#.

in my application i have 4 textboxes. they are 1. Textbox1

                                                                         2.Textbox2

                                                                         3.Textbox3

                                                         &nb

WPF Textbox loses original values, even if the user doesn't udpate

  

Hi,

I am having a very strange issue. I have a datagrid which is binding to an observable collection of type Person The selected item is bind to an Object Person. I have 2 textboxes firstname and lastname. When ever user selects an item from grid, the textbox values gets populated. user can edit the values and click submit button, values gets updated.

Source to Target works correctly - i.e. able to display from viewModel When I update the values gets updated.

Lets say user selected an item with firstname john, lastname smith The problem is user edits the firstname to johnny and he doesn't click submit button instead he selects a different item from datagrid, so when I go back to the original selected item. In the grid the selected item is shown as John smith, but in the textbox the value is shown as Johnny smith.

How to solve this problem? Any help would be greatly appreciated.


WPF Textbox loses original values, even if the user doesn't udpate

  

Hi,

I am having a very strange issue. I have a datagrid which is binding to an observable collection of type Person The selected item is bind to an Object Person. I have 2 textboxes firstname and lastname. When ever user selects an item from grid, the textbox values gets populated. user can edit the values and click submit button, values gets updated.

Source to Target works correctly - i.e. able to display from viewModel When I update the values gets updated.

Lets say user selected an item with firstname john, lastname smith The problem is user edits the firstname to johnny and he doesn't click submit button instead he selects a different item from datagrid, so when I go back to the original selected item. In the grid the selected item is shown as John smith, but in the textbox the value is shown as Johnny smith.

How to solve this problem? Any help would be greatly appreciated.


WPF Textbox loses original values, even if the user doesn't udpate

  

Hi,

I am having a very strange issue. I have a datagrid which is binding to an observable collection of type Person The selected item is bind to an Object Person. I have 2 textboxes firstname and lastname. When ever user selects an item from grid, the textbox values gets populated. user can edit the values and click submit button, values gets updated.

Source to Target works correctly - i.e. able to display from viewModel When I update the values gets updated.

Lets say user selected an item with firstname john, lastname smith The problem is user edits the firstname to johnny and he doesn't click submit button instead he selects a different item from datagrid, so when I go back to the original selected item. In the grid the selected item is shown as John smith, but in the textbox the value is shown as Johnny smith.

How to solve this problem? Any help would be greatly appreciated.

 


How to calculate days from two date textbox?

  

have two text box on which I give two date input by using rapid application development datepicker textbox. I have another text box on which I wanna show the duration of those two text box date.
I want to calculate total days of those to date. Can anyone please provide me a solution?


Copying textbox values between tabpanels in a tabcontainer control

  

I am new to AJAX.  I need to copy the values of certain textboxes on one tabpanel to textboxes on another tabpanel.  Whatever I try does not work.  I have tried the following javascript code.:

var txtName = document.getElementById('txtName');      -  this compiles but txtName is always null

var txtName = document.getElementById('<%=txtName.ClientID%>').value;  this fails to compile.

 

I have tried viewing the source file at run time and grabbing the ID and appending that in the above, but again the values is always null at run time.

 

My app is written in C#.  Do I need to do something more elaborate or is there a simple, javascript solution?

 

Thanks

 

 


Passing values from textbox to labels on another page

  

I have a form with a combination of dropdownlists and textboxes that I want to be able to show a user as a summary in another page before submitting to a sql server. Page 1 will have a verify button which will then pass the dropdown and text box info to page 2 where end users will be able to either submit the page or cancel the action. What's the best way to pass the values from page 1 to page 2?

Thank you,


Doug 


Append string values to an asp.net textbox.

  

I created a number pad using imagebuttons.  We have touch screen monitors and I was appending the string value of the button on the server side, but it was flashing every time you pressed a button.  So I want it when the press the ImageButton that says 1 on it to append 1 to the contects of the textbox.

This is the HTML code for the asp.net imageButton.

<asp:ImageButton ID="imgNumberPadButton1" runat="server" ImageUrl="~/App_Themes/Images/NumberPadButtons/Button1.png" onclientclick="PressNumber1();return false;"/>

Here is my Javascript.

<script type="text/javascript">
        function PressNumber1()
        {   
            var currentText = document.getElementById('tbxEnter').innerText;
            var newText = currentText + '1';
            document.getElementById('tbxEnter').innerText = newText;
        }
</script>
 
I also tried this.
document.getElementById('tbxEnter').innerText += '1';

It just keeps displaying 1 in the textbox.  I need to continue to append numbers into the aspNet textBox and then submit the contents to the server when a different imageButton is

Categories: 
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