.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
MarieAdela
Imran Ghani
Post New Web Links

highlighting text using javascript

Posted By:      Posted Date: August 30, 2010    Points: 0   Category :ASP.Net
 
Hi,I need to have a feature when user can highlight text just like we do in microsoft word document.  It needs to be saved and have it appeared at a different place.  I just don't know where I can start with this....will Javascript be the easiest way to go for this?....any tips for starting is appreciated.  Thanks.


View Complete Post


More Related Resource Links

Mission Impossible? Use Javascript to Disable a Multi-Line Rich Text Field

  

Hey Community,

Here's a tough one that I have struggled with and so far have not been able to find an answer for - how do you use Javascript to disable a multi-line rich text field.  I have customized a SP Edit form by adding a CEWP.  In the CEWP I have added the Javascript below (only a partial code sample provided) to disable several fields in the form.  The code works fine for single line text fields but it does not work for multi-line rich text fields.  Any suggestions?

<script language="javascript">
//This runs the function when the form first loads
_spBodyOnLoadFunctionNames.push("lockFields");

//This locks the fields the users should not modify
function lockFields()
{
  var theInputTFTitle = getTagFromIdentifierAndTitle("Input","TextField","Title");
  theInputTFTitle.readOnly = true;
  theInputTFTitle.style.color = 'gray';
  //alert(" Value: " + theInputTFTitle.value);//for testing

   var theInputDDLReplyStatus = getTagFromIdentifierAndTitle("select","DropDownChoice","Reply Status");
  theInputDDLReplyStatus.disabled = true;
  //alert(" Value: " + theInputDDLReplyStatus.value);//for testing

  var theInpu

Javascript error on Rich Text Editor of CEWP

  
Hi all,

I have a problem that is really bugging and I wasn't able to find any workaround all day. I'll try to give as many details as possible:

I'm maintaining several site collections on a single server and this problem occurs only on one of the site collections. However it occurs on all subsites of this collection, it occurs on old pages and newly created pages, even on pages containing only one empty CEWP.

When I'm pressing the button for Rich Text Editor of CEWP I get the following error:

Message: Invalid argument.
Line: 5740
Char: 2
Code: 0
URI: http://www.dyrlaegeankenaevn.dk/_layouts/1030/HtmlEditor.js

I've tracked down the error with IE developer tools and I found that the error pops up in HtmlEditor.js at

function RTE2_GenerateLaunchArguments(parameterArray, webUrl, containerID)
{
    ............some code goes here......................
    elem=document.getElementById(containerID);
    ............some code goes here......................
}

I followed containerID down the stack and it comes from:

Get the Dropdownlist text and value using Javascript from client side

  
Hi, I am encountering a problem about how to get the Dropdownlist text and value using Javascript from client side. I am using C# in Visual Studio 2005 and Javasript . The example codes are like: ( In this example code, I would like to access the text and value of the DropDownListReports in the run() function of Javascript. How can I do that? Any ideas? Thanks a lot. ) protected void Page_Load(object sender, EventArgs e) {              if (!Page.IsPostBack)               {                     DropDownListReports.Items.Clear();                     ListItem listItem = new ListItem();                     listItem.Text = "aText";                     listItem.Value = "aValue;                     DropDownListReports.Items.Add(listItem);         &nbs

Replacing a text question in a Survey using JavaScript at runtime (document.body.innerHTML.replace)

  
Hi, I want to replace some of the text in a SharePoint Survey at runtime.  The idea behind that is to add a "header" or "title" to questions that are related together.  For example, let's say I have 2 related questions, a page separator, and 2 more related questions: (yes/no type of questions): Q1.  Are you between 20 and 40? Q2.  Did you went to college?   --page separator-- Q3.  J2EE Q4.  C/C++ The result on the final Survey should look like this: Tell us about you. Are you between 20 and 40?  Did you went to college?   --page separator-- Indicate what programming languages you know: J2EE C/C++ Simply, I tried to use the document.body.innerHTML.replace() in order to replace:  - Q1 with: <h2>Tell us about you.</h2>  - Q2 with ''  - Q3 with: <h2>Indicate what programming languages you know:</h2>  - Q4 with: '' Using the technique below, I added the following code in SharePoint Designer in NewForm.aspx: <asp:Content ContentPlaceHolderId="PlaceHolderTitleAreaClass" runat="server"> <script id="onetidPageTitleAreaFrameScript"> document.getElementById("onetidPageTitleAreaFrame").className="ms-areaseparator"; document.body.innerHTML = document.body.innerHTML.replace(/Q1/g,'

Find the RootNode text/value of TreeView control using Javascript

  

Hi,

Is it possible to find the text/value of the Rootnode  of Treeview control using javascript.

Thanks,

Reena


Can we change the "specify your own value" Text when you are using fill-in choice using javascript?

  

Can we change the "specify your own value" Text when you are using fill-in choice using javascript?

I need to change the text? If you guys know anything on this, let me know. 

Thanks


highlighting the text of the selected item in Ajax Combobox

  

Is there a way to programmatically select the entire string of the selected item in the AJAX Combobox?


What I'm trying to do is bascially on a State/City selection.

1.  User selects a State from the first combobox.  This triggers the City combobox to be populated.  The item(0) is "Select One:".

2.  I want the entire "Select One:" to be hightlight as if the user had used their mouse and highlighted all the text.

The reason for this that I'd like the user to be able to start typing the city without needing to clear out the "Select One:" manually.


Can this be done?


Capture large text return from Javascript function

  

I have a Javascript function that writes a large scale of text into a div for now, but then I need to capture the text and use it in code behind. I tried to use hidden field but it has size limit so it didn't work.  The text is shown in the page, but when I view source, there is no text in the div so I couldn't use code behind to read the text from the div even though runat is server because the text is always empty. Any suggestions? Thanks!!!


How to change a label.text from Javascript?

  

Hi,

I got a regular Javascript.

How to change a label.text from a javascript?

Thanks, Gil.


Text Change for Text Box not firing when changing the text from Javascript

  

Hi,

 

I have a web page on which  I show a popup window on a button click which on closing updates text in a textbox on my webpage, I have text change event on this text box, this event is geting fired when I type something in text box and come out but its not firing when the text is change by my javascript function which is called by the popup window, anybody faced similar issues? please let me know how to handle this!!

 

thanks in advance

 

 


asp dropdown - onchange="javascript: select_country(this.options[this.selectedIndex].text);"

  

With a regular form drop-down box I can use the onchange event to fire off some javascript with out a page refresh or postback to the server. The above code is not working with an asp drop-down control. Is there a way to make this work? 

I have form that hides and shows different textboxes depending on selected values in a dorp-down but it does cause a postback which refreses the screen I want to do this wiithout refreshing the screen and figured Javascript and hide and show divs etc would work.


<script type="text/javascript" language="javascript">
function select_country(selectedcountry)
{
var country = selectedcountry;

if(country == "United States")
{
//do nothing;
}
else
{
// hide state drop-down and the state label.
// code goes here...............
} } </script>




The drop-down:

<asp:DropDownList ID

How do I get text from people picker textarea using javascript only

  

hi

 

I would really really like to know how to get the text that is displayed in a people picker field into another single line text field

upon clicking OK in a NewForm.aspx or EditForm.aspx, or onchange of the people picker field.

 

the solution needs to be limited to javascript or something that can be done via sharepoint designer, as I do not have access to install anything on the server, but I do have site owner access.

 

thank you in advance.

 

cheers

Dinesh


ASP.NET, HTML, JavaScript Snippet Support (VS 2010 and .NET 4.0 Series)

  
This post covers another useful improvement in VS 2010 - HTML/ASP.NET/JavaScript snippet support. Snippets allow you to be more productive within source view by allowing you to create chunks of code and markup that you can quickly apply and use in your application with a minimum of character typing.

Visual Studio has supported the concept of "snippets" for VB and C# in previous releases - but not for HTML, ASP.NET markup and JavaScript. With VS 2010 we now support snippets for these content types as well.

call JavaScript - jQuery code from ASP.NET Server-Side

  
jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side.

Highlighting Rows with TextBox OnFocus

  
In another article I explained that how you can make the rows of the GridView control clickable and highlight them when they are clicked. In this article I will explain that how you can highlight the GridView rows when you focus on the TextBox which is contained inside the GridView control.

call JavaScript - jQuery code from ASP.NET Server-Side

  
jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side

Ajax Enabled Gridview using JavaScript in ASP.NET

  
Before explaining the article, I would like to thank all readers who read my article and voted for it. Your appreciation for my article gives me strength to write more good articles. Hope in future I will get your valuable comments and suggestions. Now I won't waste your time and come back to the topic. I have written this article on 'Ajax Enabled Gridview Using JavaScript in ASP.NET'. In this article, I will show you how to make a Gridview using a simple HTML table, JavaScript and XML HTTP for Ajax call without using any ASP.NET control.

Using Code
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend