Click here to Skip to main content
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 disabled the 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 CHill60 280
1 Sarvesh Kumar Gupta 238
2 Sergey Alexandrovich Kryukov 203
3 OriginalGriff 163
4 DamithSL 153


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