RadSpell display redlines - c#

I have a multiline checkbox. I want to use RadSpell.
But everytime I insert text on the textbox it doesn't display red lines.
How can i do this?
here is my code.
<telerik:RadTextBox ID="textbox1" runat="server" TextMode="MultiLine" Rows="4"
Columns="51" Width="401px" Font-Size="10" Font-Names="Calibri" />
<telerik:radspell id="RadSpell1" runat="server" DictionaryLanguage="English"
controltocheck="textbox1" spellcheckprovider="PhoneticProvider"
supportedlanguages="en-US,English" ButtonType="None"/>
NOTE: No buttons needed.
I just want to show all the words that are misspelled.

That's a browser feature - inline spellchecking. All modern browsers have it. Well, IE doesn't, but why should we call it modern? ;-)
What RadSpell can do for you is a popup with suggestions and information.
EDIT: Forgot to mention you can trigger RadSpell's check programmatically: http://www.telerik.com/help/aspnet-ajax/spell-client-side-api.html. Look for the startSpellCheck() method. For example in the onblur event.

Related

How do I display an image within the HiddenField asp.NET field?

Note: I'm just an lowly intern here, so be nice :) I've spent some time researching before asking but didn't find the answer I'm looking for.
Suppose I have a line in my .aspx file like so:
<asp:HiddenField runat="server" ID="hiddenfield" Value=??? >
What should I put for the value if I would like this hidden field to display a .png image when shown?
Sorry I can't give much more detail, I don't want to violate my company's policies. If you need any more information, let me know and I'll try to give an example.
If you want to display an image, you should use the Image control.
If you want to hide it, wrap it in a div and set the visibility to hidden. For example:
<div id="divHidden" style="visibility: hidden">
<asp:Image runat="server" AlternateText="this is an image" ImageUrl="/img/myimage.gif"/>
</div>
May be you can save image path only in hidden field using this.
<asp:HiddenField runat="server" ID="hiddenfield" Value="/img/myimage.png" >
And later retrieve that using javscript document.getElementById("hiddenfield").value , and set that path to actual img element if needed.
You probably want to use:
<asp:Image ID="myImage" ImageUrl="myimage.png" Visible="false" AlternateText="foo" />
And when you need to show it from your codeBehind:
myImage.Visible=true;

Change password is firing when the enter key is hit in any textbox

I have a searchbar on my site, but the problem is that when the user is in their profile I display a changepassword asp.net object. I'm using Visual Studio 2012.
<asp:ChangePassword ID="ChangePassword1" runat="server" SuccessTextStyle-HorizontalAlign="Center" CancelButtonText="" CancelButtonType="Link" ContinueButtonText="" ContinueButtonType="Link">
</asp:ChangePassword>
When I try to add my searchbar
<asp:TextBox ID="txtSearch123" runat="server" OnTextChanged="txtSearch123_TextChanged" Width="217px" Text="Search for an item..." OnClick="this.value=''" AutoCompleteType="Disabled"></asp:TextBox>
When the user presses enter, the search never completes because the textboxes inside in the change password are empty and they light up as if the user is trying to change their password. Even though they aren't linked what so ever.
Any ideas?
Following Works:
<asp:ChangePassword ID="ChangePassword2" runat="server" ValidationGroup="Password"> </asp:ChangePassword>
<asp:TextBox ID="txtSearch123" runat="server" OnTextChanged="txtSearch123_TextChanged" Width="155px" Text="Search for an item..." OnClick="this.value=''" AutoCompleteType="Disabled" ValidationGroup="SearchItem"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="" Width="0" Height="0" ValidationGroup="SearchItem" Visible="false" />
IF that does not work, do the following...
Make a button with the same validation as the text box.
Set the height and width to the button to 0.
Set the border type to none
Set the background of the button to the background you are trying to place it on.
Boom, your button is hidden in plain sight and your validation group still works.
<asp:TextBox ID="txtSearch123" runat="server" OnTextChanged="txtSearch123_TextChanged" Width="217px" Text="Search for an item..." OnClick="this.value=''" AutoCompleteType="Disabled" ValidationGroup="SearchItem"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="" Width="0" Height="0" ValidationGroup="SearchItem" BackColor="#5F605F" BorderStyle="None" />
There's two concepts you need to understand first.
The fact is, that everything on a (normal) ASP.NET page is inside one single form. This also means that things like "pressing enter to send form" are a bit tricky, since they submit the whole form, which usually isn't what you want.
Now to the concepts:
ValidationGroup - this setting on .NET validators (and buttons etc.) allows you to separate different logical forms inside the one superform. The validators will only evaluate if the originator of the submit action (eg. the "change password button") is in the same ValidationGroup. Properly configuring validation groups should make this part of your issue disappear.
What happens on enter key press - by default, you send the whole form, without doing any button's action. So, if you have multiple logical forms on one page, you have to put each inside its own Panel, which has a DefaultButton property, which says "if I press enter inside this panel, it will act as if I clicked on this button".
SET ValidationGroup in your TextBox
<asp:TextBox ID="txtSearch123" runat="server" OnTextChanged="txtSearch123_TextChanged" Width="217px" Text="Search for an item..." OnClick="this.value=''" AutoCompleteType="Disabled" ValidaionGroup="Something"></asp:TextBox>
Specifying Validation Groups

use Javascript or C# to validate a webform

Would like to validate more than one control on one button click. I would like something to validate whether a textbox has contents if a checkbox is checked or not but the checkbox doesn't necessarily have to be checked and in that case I don't want to check the textbox. I tried validation group but each button needs to control the different groups and i need this all to be under one button.
I'm open to ideas of how to do this c#,javascript...etc. Heres some code: Button3 is the save which validates whether checkbox 1 is checked and if so textbox10 cant be empty. I have about four other instances of this but are independent of each other.
<asp:Button ID="Button3" runat="server" Height="24px"
Text="Save" Visible="False" Width="67px" Font-Bold="True"
causesvalidation="true"
validationgroup="required"
runat="Server" />
<asp:CheckBox ID="CheckBox1" runat="server"
oncheckedchanged="CheckBox1_CheckedChanged" Text=" Breach Letter Sent"
ValidationGroup="required" AutoPostBack="True" Enabled="False" />
You want to use the CustomValidator control which can validate both on the server and the client. There is an example in the docs here - http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.customvalidator.aspx
I would never do form validation in JavaScript. Believe it or not, but some people actually turn off JavaScript! Use validators to validate the field content. Of course this means a round trip to the server in most cases, but you get reliable and well integrated validation.
you can use validation with Ajax (in Ajax postback occures but you will not sense)

TextChanged event not firing

I have a GridView and a TextBox in one of its fields:
<asp:GridView ID="NTSBulkEditGridView" runat="server" AutoGenerateColumns="false" AllowSorting="true" Height="500px"
DataKeyNames="BookStem" OnRowDataBound="NTSBulkEditGridView_RowDataBound" DataSourceID="NTSSqlDataSource">
<Columns>
<asp:TemplateField HeaderText="Priority" SortExpression="Priority">
<ItemTemplate>
<asp:TextBox ID="txtPriority" runat="server" Text='<%# Eval("Priority") %>' BorderStyle="None" Width="80%" OnTextChanged="TextBox_Changed" AutoPostBack="true"></asp:TextBox>
<asp:CompareValidator ID="PriorityCompareValidator" runat="server" ControlToValidate="txtPriority" Display="Dynamic" ErrorMessage="Priority must be an integer!" Text="*" Operator="DataTypeCheck" Type="Integer" ValidationGroup="InsertUpdateNewTitlesStatusValidation" ></asp:CompareValidator>
</ItemTemplate>
</asp:TemplateField>
...
Could you please tell me why TextBox_Changed() is never called when I change text and press Enter? I tried to put same kind of a TextBox outside of the GridView, and there it works.
Thanks.
TextChanged of an ASP.NET TextBox translates into blur JavaScript event. And blur occurs when the text of the input element is changed and the input element loses focus. Try to change the text, but don't hit Enter. Simply hit TAB key to go to next field. Does it fire post back?
Update:
Well, I saw that link. Two things. First, if you notice, it goes back to 2005 and ASP.NET 2.0 and we all know that 6 years in the world of computer means 60 years. So that article is obsolete by now. Second, sometimes a pattern only exists in articles, and you rarely see it in real productive systems. How many bulk actions have you seen on the web? And what type do they have? Consider Gmail, or Yahoo mail for example. You can mark 20 or 30 or X number of emails as read in one shot. But, can you respond to 20 mails in one step? Nope, just because it doesn't make sense. I've never seen a bulk action on a text box in web world. I think you'd better stick to use AJAX, with better performance, and more user acceptance. :)

Handling the submit action of two TextBoxes

I have an ASP.net page.
That has an Ajax Toolkit Tab Control.
That has tabs.
That have custom ascx controls I wrote.
I have a text box that perform a search action. It is declared like this:
<asp:TextBox ID="txtPrereqSearch" runat="server"
ontextchanged="txtPrereqSearch_TextChanged"></asp:TextBox>
Nothing fancy. This format has been working for months. There's no submit button. It just posts back when I hit enter. The problem appeared when I added a second custom control using the same type of feature. Now browsers don't postback when I type something in either of these textboxes and press enter.
It seems that browsers have a default way of handling one textbox in one form, but that behavior changes when the number reaches two.
Is there an easy way around this? I guess I can create a hidden submit button but it seems like there is probably a better way to deal with this when the functionality is in two separate custom controls.
Your feedback is appreciated!
Check this out: http://www.allasp.net/enterkey.aspx
The default behavior with no submit button seems to depend on the browser, and the behavior can indeed depend on the number of input controls.
I would add hidden "submit" button (e.g. style="display:none;") which should ensure that it always gets submitted.
The answer was a little different than I expected, but philosophically like my original idea that #jamietre reinforced.
I had to surround the controls with an <asp:Panel> tag with a DefaultButton attribute. A-like-a so:
<asp:Panel ID="ButtonPanel" runat="server" DefaultButton="btnSubmit">
<asp:Label ID="Label1" runat="server" Text="Course:"></asp:Label>
<asp:TextBox ID="txtPrereqSearch" runat="server"
ontextchanged="txtPrereqSearch_TextChanged"></asp:TextBox>
<asp:TextBoxWatermarkExtender ID="txtPrereq_TextBoxWatermarkExtender"
runat="server" Enabled="True" TargetControlID="txtPrereqSearch"
WatermarkCssClass="Watermark" WatermarkText="e.g., MATH201"></asp:TextBoxWatermarkExtender>
<asp:Button ID="btnSubmit" CssClass="InvisibleSubmit" runat="server" Text="Submit" OnClick="txtPrereqSearch_TextChanged"/>
</asp:Panel>

Categories