Hi all
I have javascript function that insert text into freetextbox at current cursor position. It works well when I call this function onClientClick event passing a string as a parameter (This string is inserted into freetextbox at current cursor position). My code is as follow

<FTB:FreeTextBox id="FreeTextBox1" toolbarlayout="ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorsMenu,
FontForeColorPicker,FontBackColorsMenu,  runat="Server" DesignModeCss="designmode.css" EnableSsl="True" Focus="True"/> 
  <asp:Button ID="btnInsert" Text="Insert Text" CssClass="button" runat="server" OnClientClick="insertValue('abc');" /> 
<script language="javascript" type="text/javascript"> 
 function insertValue(field) {
FTB_API['<%=FreeTextBox1.ClientID%>'].Focus();
FTB_API['<%=FreeTextBox1.ClientID%>'].InsertHtml(field);
FTB_API['<%=FreeTextBox1.ClientID%>'].Focus();
window.event.returnValue =false;
}
</script>

The above code is working fine and insert string 'abc' into freetextbox's cursor position
But I want to insert string from code behind file in C#.Net (Server side text)
For this purpose I removed the OnclientClick from btnInsert and passed called this javascript function on page load but it does not work
The New code is given below
//Code Behind

protected void Page_Load(object sender, EventArgs e)
{
string str = "Abc"; 
btnInsert.Attributes.Add("OnClick", "insertValue('" + str + "')");
}
//HTML Code It is same as above except OnClientClick="insertValue('abc') has been removed.
<FTB:FreeTextBox id="FreeTextBox1" toolbarlayout="ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorsMenu,
FontForeColorPicker,FontBackColorsMenu,  runat="Server" DesignModeCss="designmode.css" EnableSsl="True" Focus="True"/> 
  <asp:Button ID="btnInsert" Text="Insert Text" CssClass="button" runat="server" /> 
<script language="javascript" type="text/javascript"> 
 function insertValue(field) {
FTB_API['<%=FreeTextBox1.ClientID%>'].Focus();
FTB_API['<%=FreeTextBox1.ClientID%>'].InsertHtml(field);
FTB_API['<%=FreeTextBox1.ClientID%>'].Focus();
window.event.returnValue =false;
}
</script>

I am also using AJAX Scriptmanager on my webpage.

Qasim, I would love to help but find that code completely impenetrable. It's neither HTML not Javascript, so this may not be the right forum.

You could try posting what is actually served to the client (view source in the browser), rather than the server-side script. However you would then need to "reverse-engineer" any solution offered back into funnyScript.

Alternatively, maybe someone will recognise the code and be able to help directly.

Sorry to be negative, but maybe better than getting no replies at all.

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.