Click here to Skip to main content
11,648,785 members (81,924 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
i have used javascript.Value from this javascript i have fill textbox.textbox is now fill with value(Ex:200) But problem is ..when this textbox is disable,value in it cannot be inserted into database.if textbox is not disable then value is insert in database.
i have to do textbox disable and insert value into database.how i can do this?
Posted 25-Jan-13 10:30am
Edited 25-Jan-13 10:32am
v2
Comments
richcb at 25-Jan-13 16:33pm
   
What method are you using to update or insert into a datase and what type of database?
Member 9511889 at 25-Jan-13 16:45pm
   
SqlCommand cmd = new SqlCommand("insert into StudentFees(" + Convert.ToInt16(ddlstudentname.SelectedValue) + "," + Convert.ToInt64(txt_totalfees.Text) + "," + Convert.ToDateTime(txtNextPaymentDate.Text) + "'," + Convert.ToInt64(txt_nextpaymentAmt.Text) + ")", cnn);

total fees is comming from javascript.i have to store it in sql table "studentfees"
richcb at 25-Jan-13 17:31pm
   
Well I am not sure what event this insert statement is taking place so I can't tell what the problem is. But if you are disabling the textbox onblur then it won't get the value to the database because it is essentially invisible after disabling it. Also, your insert statement does not specify columns to insert your values into.
Prosan at 26-Jan-13 3:47am
   
how you disable text box
Tharaka MTR at 28-Jan-13 1:46am
   
please send us code sample
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Please make the textbox property to readonly.If you disabledthe Textbox property the value cannot be read.

Thanks
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

It will be great if you could share little more details about when you are inputing data and when you disable it.... but based on the info you provided.. I would say

Maintain a hidden text field which can capture the data from disabled field, and use the hidden field for retrieving data.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

since you have set its value using javascript you will be required to use the following way to get the value

string myValue = Request["txt_totalfees"].ToString();
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Don't disable the TextBox in the CodeBehind, add the attribute

means

TextBox1.Enabled = false;

instead of this use below code..

TextBox1.Attributes.Add("disabled", true);
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Dont disable textbox.
User ReadOnly = true;
or Enabled = false;
or Visible = false;
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 F-ES Sitecore 354
1 OriginalGriff 324
2 Kornfeld Eliyahu Peter 309
3 CPallini 295
4 Sergey Alexandrovich Kryukov 254
0 OriginalGriff 1,577
1 Sergey Alexandrovich Kryukov 1,087
2 CPallini 1,015
3 DamithSL 996
4 jyo.net 994


Advertise | Privacy | Mobile
Web04 | 2.8.150804.4 | Last Updated 28 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100