Click here to Skip to main content
12,634,030 members (24,048 online)
Rate this:
 
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 11:30am
Updated 25-Jan-13 11:32am
v2
Comments
richcb 25-Jan-13 16:33pm
   
What method are you using to update or insert into a datase and what type of database?
Member 9511889 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 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 26-Jan-13 3:47am
   
how you disable text box
Tharaka MTR 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161208.2 | Last Updated 28 Jan 2013
Copyright © CodeProject, 1999-2016
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