473,388 Members | 1,383 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Call Javascript fromASP.NET

Hi!

I have a javascript function in my .aspx page

function insertField(field)
{
var TxtArea = document.getElementById("FreeTextBox1");

if(document.selection)
{
if(FTB_API['FreeTextBox1'].mode==FTB_MODE_DESIGN)
{
var DesignView=document.getElementById("FreeTextBox1_d esignEditor");

DesignView.contentWindow.document.body.focus();
sel = document.selection.createRange();
sel.text = field;
}
else
{
var TxtArea = document.getElementById("FreeTextBox1");
TxtArea.focus();
sel = document.selection.createRange();
sel.text = field;
}
}
else if (TxtArea.selectionStart || TxtArea.selectionStart == '0')
{
var startPos = TxtArea.selectionStart;
var endPos = TxtArea.selectionEnd;
TxtArea.value = TxtArea.value.substring(0, startPos) + field + TxtArea.value.substring(endPos, TxtArea.value.length);
}
else
{
TxtArea.value += field;
}
}

This function inserts text in the current cursor position in FreeTextBox Control.

The code is working fine when I call this function from an HTML Link
<a href="javascript:insertField('HELLO')" class="primw">Insert Image</a>

But when I call the function from ASP.NET it is not working
ls_work = "<script language=javascript> insertField('HELLO'); </script>";

Page.RegisterClientScriptBlock("MyScript", ls_work);


Any Help????
Dec 28 '07 #1
1 1542
Hi!

I have a javascript function in my .aspx page

function insertField(field)
{
var TxtArea = document.getElementById("FreeTextBox1");

if(document.selection)
{
if(FTB_API['FreeTextBox1'].mode==FTB_MODE_DESIGN)
{
var DesignView=document.getElementById("FreeTextBox1_d esignEditor");

DesignView.contentWindow.document.body.focus();
sel = document.selection.createRange();
sel.text = field;
}
else
{
var TxtArea = document.getElementById("FreeTextBox1");
TxtArea.focus();
sel = document.selection.createRange();
sel.text = field;
}
}
else if (TxtArea.selectionStart || TxtArea.selectionStart == '0')
{
var startPos = TxtArea.selectionStart;
var endPos = TxtArea.selectionEnd;
TxtArea.value = TxtArea.value.substring(0, startPos) + field + TxtArea.value.substring(endPos, TxtArea.value.length);
}
else
{
TxtArea.value += field;
}
}

This function inserts text in the current cursor position in FreeTextBox Control.

The code is working fine when I call this function from an HTML Link
<a href="javascript:insertField('HELLO')" class="primw">Insert Image</a>

But when I call the function from ASP.NET it is not working
ls_work = "<script language=javascript> insertField('HELLO'); </script>";

Page.RegisterClientScriptBlock("MyScript", ls_work);


Any Help????
The problem is in this code
FTB_API['FreeTextBox1'].mode==FTB_MODE_DESIGN
IT IS GIVING ME THE FOLLOWING JS ERROR: "object error"

maybe it is from the freetextbox.dll?
Jan 2 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: hrishikesh | last post by:
hi all can you tell me how to call javascript function in .aspx page i want to call it on onclick of button this codebehind code giving me some other problem like The viewstate is invalid for...
4
by: verci | last post by:
Hi guys, I'm running asp.net 2.0. Does anyone know how to fire or call a javascript function from inside my (VB.aspx) code without assigning it to a control attribute? thank you
1
by: santosh2003 | last post by:
Hi All, How would we call Javascript function on img click? can we call function which define in codebehind page (.vb page) on img click? Regards Santosh
2
Inbaraj
by: Inbaraj | last post by:
Sir, I want to call javascript code in Asp.net(C#) page. I have done this before but i forget the keyword to run the javascript in asp.net page.... Help me in this matter.... Thanks...
5
by: mmr315 | last post by:
how to call javascript variable in to phpcode in the same form please help me how to call
2
by: wolverine2512 | last post by:
Hello .Net Wizards! I would like to seek your help on how to call javascript function from code behind of VB.net. I have javascript function named Openform() and i want to execute it on page load,...
1
KalariaNitya
by: KalariaNitya | last post by:
hello dear, i need ur help i read ur answer in http://www.dotnetspider.com/qa/Question39518.aspx regarding that i want to ask u that, if i used Text1.Attributes.Add("onblur", "return...
1
by: siddu | last post by:
How to call Javascript function in single statement, I have to call these two statements in a single onClick img.Attributes("onclick") = "toggleSidebar(" + IDPREFIXSIDEBARCONTENT + CStr(tab.Id) +...
1
by: Prajaktaj | last post by:
Hi All, I am working on sharepoint and I have included the content editor web part in it. There we can write the html file in it. I know that we can call javascript functions from html by using...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.