I need to create like a panel made out of text for example
MY PANEL
Drag any of the items below into the editor:
CUSTOMER
BUSINESS_PHONE
BUSINESS_ADDRESS
So when dragging this into the editor it will add it in the following way
This is an example of how [[CUSTOMER]] has improved his business.
You may contact them directly by dialing [[BUSINESS_PHONE]].
Its like creating a template. I am just not sure what to use to make this work.. We are using a RadEditor. Any suggestions would be much appreciated, please note that we can not change the editor since we use in many multiple places the solution if there is any has to integrate with the editor.
Thank you very much
I've done something similar to what you're attempting to achieve, you will have to add some code to that instance of the radEditor, specifically add in some Javascript to your OnClientLoad function to catch the drop event and then handle the data appropriately. The tricky part is maintaining cursor positioning since you will have to parse the HTML once it's dropped not before.
I would really suggest if possible to use an insert button and a list/object that you can select from, click the button and have it inserted at the cursor, it's much easier to implement.
However here's the code without the parsing of how I attached the drop event to the editor, I'm using a RadPanelBar to drag and drop from. This even will fire with anything drag and dropped into the editor, I'd also suggest using some kind of markup like <span class="dragableItem">BusinessPhone</span> that you can look for when parsing your content.
If you could make your list simply [[BusinessPhone]] and drag and drop that in that would obviously be the simplest solution, although not elegant.
function OnClientLoad(editor)
{
var element = document.all ? editor.get_document().body : editor.get_document();
//var eventHandler = document.all ? "drop" : "dragdrop";
var eventHandler = "drop";
$telerik.addExternalHandler(element, eventHandler, function(e) {
setTimeout(function() {
contentDropped(editor);
}, 300);
});
//....
}
function contentDropped(editor)
{
var content = editor.get_html();
//parse the content of the editor
editor.set_html(content);
}
Related
I have a little help pop-up that displays some text when the user presses a "?" label next to a drop-down to explain the different selections.
I did it using the Help.ShowPopup command since that seemed the easiest.
I was hoping there was a way to add different font properties to parts of the text or at least to the whole thing without having to go the direction of a CHM/HTML help-file.
Here is what I am trying to do:
private void helpLbl_Click(object sender, EventArgs e)
{
// for some reason, it ignores the 'parent' parameter
// and lays it out on the screen's coordinates
Point helpLocation = helpLbl.PointToScreen(Point.Empty);
helpLocation.Y += helpLbl.Height; // have it display underneath the control
Help.ShowPopup(this, // hosting form
#"<b>Fixed:</b>
Removes a fixed amount from the sale
<b>Percent Value:</b>
Removes a set percentage of the selected package from the sale
...", helpLocation);
I was hoping since there's the option to use an HTML document to display the help, I could use HTML tags to format what was being displayed, but it doesn't appear so. Any ideas?
Is there a way to do something like displaying a RichTextBox in the help pop-up?
Another possibility is generating a HTML document on-the-fly, but it asks for a "url" if I'm not supplying the text directly and I think that might be a little over-kill for the small amount I'm trying to do here.
You have two options. One is to use a WebBrowser Control. This natively accepts HTML and displays it. The problem with it is its kind of bloated just to use as a simple label.
Your second option is to simply create a RichTextLabel, simply like this:
public class RichTextLabel : RichTextBox
{
public RichTextLabel()
{
BorderStyle = BorderStyle.None;
}
}
Add this to your form and set the Rtf property to your RTF code. You will have to convert your HTML to RTF, which is easy if you got a program such as Microsoft Word, for example.
There are a bunch of websites with "search" input boxes.
If I input a word manually then it automatically search without need to click any buttons.
Using the following code:
GeckoInputElement input = (GeckoInputElement)geckoHtmlElement;
input.Value = "searchword";
The I see that search input box is filled but nothing happens automatically.
If I manually add space or any character then website works as expected.
Auto searches my wanted word.
I tried using input.Focus(); but still same.
Any ideas how I can input text into search box in a more advanced way or something like that?
I think the solution here is to manually trigger the event that triggers the search - for example the keyup event. I had the same problem which I solved by adding this code:
nsAStringBase eventType = (nsAStringBase)new nsAString("keyup");
var ev = browser.Document.CreateEvent("HTMLEvents");
ev.DomEvent.InitEvent(eventType, false, false);
nameBox.GetEventTarget().DispatchEvent(ev);
You would need to inspect your page and see if there are any javascript events attached to your input.
Good luck!
I got this Text box with default value as "First Name" ..Now when I click inside this text box to enter name , this value "First Name" keeps on displaying. What I want is to the text box to clear as soon as I click inside it. What property do I need to set in mt textbox tag ?
[Edit]
ok anything from Telerik that I can use to do that ?
There is not out of the box functionality in TextBox that will accomplish this, but the ASP.Net Ajax Toolkit has a Watermark Extender that will do everything you want.
I have used both, but now personally use a jQuery Watermark Plugin
Either will work just fine, choose based on your needs.
According to the Telerik docs you just have to set the EmptyMessage property on their TextBox control. Demo Page Here
In the code behind, on Page Load you can add the following code to achieve this
TextBox1.Attributes.Add("onClick", "javascript:if(this.value=='First Name'){this.value='';}");
You can use the method suggested by #Josh. If you do not want to use Ajax Toolkit controls or JQuery you could write it on your own using Javascript. Write a function which gets called when the foucs is received by the textbox control. I thik the function is called onfocus or just focus in Javascript.
Hi I just wrote this small function which will achieve your desired result
function clearInputBox(x,prefil){
if(x.value == prefil){
x.value = '';
}
}
Your input box looks like this
<input type='text' value='First Name' onfocus="clearInputBox(this,'First Name')" />
May be this will help you
Taking Shobans advice one step farther, you could add something like this to your Page subclass
protected override void OnInitComplete(EventArgs e)
{
string jsString = "javascript:if(this.value=='" + TextBox1.Text + "'){this.value='';}";
TextBox1.Attributes.Add("onFocus", jsString);
base.OnInitComplete(e);
}
What this will do is, it will always consider that default string is the one this controll contains at esign time (the initial one in your .aspx file), so you wont have to manually change it in codebehind every time you change your .aspx. Remember, that OnIinitComplete fires before any viewstate or postback data has been applied, but after the controlls on your page have been set to their default values.
P.S. As anishMarokey pointed, use onFocus vs onClick, since fields can gain focus without clicks via Tab key.
i have setup a profanity filter with bad words in a XML file and have the following function to run on my page to replace the words:
BadWordFilter.Instance.GetCleanString(TextBox1.Text);
i'm about to go through my entire site now wrapping that function around every little text variable one by one and it's going to be a huge pain in the butt
i'm hoping there's a way that i could just set my masterpage to automatically run all text through this thing on any page_load, so that the effect would be site-wide instantly. is this possible?
much appreciated for any help
One quick tip I have is to use the tag mapping feature of asp.net for this:
Create a custom textbox class derived from the TextBox class
Override the get/set Text property & in the get part, return the cleaned string
Use tag mapping feature in the web.config file to replace all TextBox classes with your custom text box class & everything should work really well.
This link has a sample implementation which uses the HTMLEncode, but you get the idea: http://www.devwebpro.co.uk/devwebprouk-46-20071010ASPNETTagMapping.html
HTH.
I realize you said Page_Load(), but I suspect this will do what you need.
In the Page.PreRender event, walk through the controls:
/* inside Page_PreRender() handler...*/
if (user_options.filterBadWords == true)
{
FilterControls(this);
}
/* this does the real work*/
private void FilterControls(Control ctrl)
{
foreach (Control c in ctrl.Controls)
{
if (c.GetType().ToString() == "System.Web.UI.WebControls.TextBox")
{
TextBox t = (TextBox)c;
/* do your thing */
t.Text = BadWordsFilter(t.Text);
}
if (c.HasControls())
FilterControls(c);
}
}
This is a hack, which will get you through your current problem: overriding the TextBox control is ultimately a better solution.
I'm creating a SharePoint web part in C# that is using an UpdatePanel for some AJAX magic. Everything is working fine, but I'd like to know how to lay out my controls visually (without using SharePoint Designer). I just have two dropdownlists, some labels, a button, and a textbox. I am creating them within the overridden CreateChildControls. Thanks!
add a container panel around your controls and give it a class. Add the panel to the UpdatePanel's container. Add all other controls to the new Panel's Controls.
You can now use css to do your styling, using the container panel's CssClass as reference.
in code:
protected override CreateChildControls()
{
// .. creation of updatepanel, say upd1
Panel container = new Panel{CssClass = "webpartContainer"};
upd1.ContentTemplateContainer.Controls.Add(container);
container.Controls.Add(dropdown1); // etc. etc.
}
The Css:
.webpartContainer
{
/* if needed add some style here also */
}
.webpartContainer select
{
/* add style */
}
.webpartContainer .specificClass
{
/* give controls a class of their own in CreateChildControls
if controls of the same type need different styling
(i.e. you have more than 1 select that need to look different) */
}
there are a couple of ways you can lay them out. you can add a Table object and add rows, cells, etc. and add your controls to the cells.
Alternately, you can override the RenderContents method and output HTML directly to the write that is passed in as a parameter. If you do this method (its probably less work and more efficient then using the Table objects), you should use a StringBuilder to build your HTML then output the results to the writer. This method should gain you some performance.
Sadly, there is no visual WYSIWIG editor for this method.
Unfortunately, there is no visual designer for web parts that are created programmatically.
You can use a user control and the SmartPart web part from codeplex to gain advantage of the visual designer for .ascx user controls.
You can use ASCX files in web parts.. just load it from your webpart class in CreateChildControls like so:
var control = Page.LoadControl("/_CONTROLTEMPLATES/yourproject/your.ascx");
Controls.Add(control);
This way you can use the normal way with Visual Studio to layout your webpart. Much nicer than building HTML in code which is a pain to say the least.
(this is also much better than using SmartPart which causes issues with the trustlevel and deployment)