I have an HTML form with a check box linked to a text input. The check box enables/disables and clears the text input (don't need to save the text value if unchecked).
Should I save this information in 2 db columns or one?
With one I figured I could use NULL if the check box is unchecked. I'm not sure what the best option is.
Thank you
You are right, field type should be text with NULL option.
null means checkbox was checked
empty means no text was entered
Related
I have a column in my database that is set to memo. I am trying to view the data in a textbox.
I have enabled new line in field from the Enter Key Behaviour property but all the data from the record is now showing - What am I missing?
The data is being pulled from a list box, example code below:
Textbox1 = listbox.column(1)
Thanks in advance
This has nothing to do with the EnterKeyBehavior property of the text box.
http://allenbrowne.com/ser-63.html
Row Source
A Memo field in the Row Source of a combo box or list box will
truncate.
Don't use memo fields in combos or list boxes.
You'll need a different method to load the text box, e.g. read the ID from the listbox and use DLookup().
AKA, if I have two fields (one radio button group and one textarea that only appears if the "other" radio button is pressed) how would I make it so the input from the text area overrides the "other" button having it's value placed in the mailto?
E.g., I want this to happen:
field1=text from text area
NOT this:
field1=other
field2=text from text area
Could I set the value of the "other" radio button in field1 to the text coming from the text area?
Alternatively, could I do anything to prevent a certain field from appearing in the mailto fields?
In future, please ensure you present SO with a code issue, not a general question or request. However, you would use a JQuery change handler, like so:
$('#mastertextboxid').on('input', function(){ //executes every time master's text is updated
$('#slavetextboxid').value($('#mastertextboxid').text()); //updates the values
})
This will overwrite any text in the slave textbox when the master textbox is changed, but the User will still be able to input into the slave textbox. It's known as One way data binding.
I've one text box and one update button:
Text box:
<asp:TextBox ID="txtFName" runat="server"></asp:TextBox>
update button:
<asp:Button ID="btnUpdFName" runat="server"Text="Update" onclick="btnUpdFName_Click"/>
What I am doing in page load event I am getting the first name from database and assinging it to text box as follows:
txtFName.Text = dt.Rows[0][1].ToString();
Now when i earases the text set at page load event in text box as above and write another name and press update button, i am trying to get the new text entered in the text box in the button click event as follows:
string FName = txtFName.Text;
But the problem is that every time I write new text in text box, I am still getting the same text as set form database (dt.Rows[0][1].ToString()).
I am not able to get the current text from the text box and getting only the intial value set from db in page load event.
What I encountered that after compilation my text box markup becomes as follows:
<input id="CPHcontent_txtFName" type="text" value="value set from db i.e. dt.Rows[0] [1].ToString()" name="ctl00$CPHcontent$txttxtFName"></input>
the text box alway has the same value set from the db. Thats why i am getting each time the same value regardless of value entered by user in text box.
Now tell me how to get the updated value of text box in my page behind.
Thanx in advance
In asp.net webforms you should separate code for setting data to control and for saving data to db. One of ways to set data to control - use check
if (!IsPostBack)
{
txtFName.Text = dt.Rows[0][1].ToString();
}
in page load event.
Otherwise you will overwrite your newly entered text for textbox on every page load.
You are probably overwriting the text you entered in your Page Load event, because you are not checking if it is a PostBack.
Please read ASP.NET Page Life Cycle Overview for further information.
Set the textbox to empty or null before you try to set/read it again onpageload.
I'm pretty sure it's not possible to do this but I'm still asking for it.
Is there a way for a user to insert a null (or an undefined) value into an html text input?
I need to distinguish between a null value and an empty string and I would like to allow the user to set this value into a single input.
For what I can see across the web, the standard solution to this problem is to match the text input with a checkbox that tell if the value is null or not. From my understanding, the limitation is linked to the fact that the textbox can hold an empty string but not a null value so that's why I think it's not possible to do exactly what I want.
You can't tell a text input to have any kind of null value. Empty checkboxes have a value of an empty string '' by definition. The best way to do it, as you say, is to have a checkbox that toggles the disabled property of the text input, which gives a similar semantic.
Necromancing.
The accepted answer is kindof wrong - there is a way, sort of.
If you set the textbox state to disabled (for example with the chrome developer tools), then it won't submit the input box's value.
Hence, if you deserialize the form model from a post-request, the text's value will be NULL, unless your deserializer deliberately changes data.
I can type text into a field using WebElement.sendKeys() but editing doesn't work: I can neither move the cursor nor delete the last character that I typed with e.sendKeys( Keys.BACK_SPACE )
How do I modify the value of a text field in Selenium 2 (WebDriver)?
You can definitely do that by either of the two methods. I have tried and it works.
e.click() # Positions the cursor at the end of the string
e.sendKeys(Keys.BACK_SPACE )
Or you could simply clear the text, and start over again:
e.clear()
e.sendKeys("What you want to send")
I found this solution that seems to work pretty well. It basically clicks on the text field WebElement, then sends Ctrl-End to put the cursor at the end of the text. Then sends the string that I had previously initialized.
(quickReplyTextArea is a text field WebElement that I have previous found, as is postQuickReplyButton (button instead of text field, obviously). replyText is a String that I initialized earlier)
quickReplyTextArea.click();
quickReplyTextArea.sendKeys(Keys.chord(Keys.CONTROL, Keys.END));
quickReplyTextArea.sendKeys(replyText);
postQuickReplyButton.click();
You can try clicking first into that text box, and use sendKeys() afterwards.