hi

I have a freetextbox, a hiddenfield and a button on my web page. By pressing the button it insert the text from hiddenfield into freetextbox at current cursor position. I am doing this task using java script. when I run the webpage it give me Object required error. The code is given below

//Javascript Code

<script type="text\Javascript">

function Show()
{
  var ctrl = 
document.getElementById("txtTargetText");
  var saveText = ctrl.value;
  ctrl.focus();
  var range = document.selection.createRange();
  var specialchar = String.fromCharCode(1);
  range.text = specialchar;
  var pos = ctrl.value.indexOf(specialchar);
  ctrl.value = saveText;
  range = ctrl.createTextRange();
  range.move('character', pos);
  range.select();
  range.text = 
document.getElementById("txtSourceText").value;
  document.getElementById("txtTargetText").focus();
  window.event.returnValue = false;
}
</ script>

// HTML Code

<FTB:FreeTextBox id="FreeTextBox1" toolbarlayout="ParagraphMenu,FontFacesMenu,FontSizesMenu,

FontForeColorsMenu,FontForeColorPicker,FontBackColorsMenu, 
 runat="Server" DesignModeCss="designmode.css"/> 
 
<asp:HiddenField ID="HiddenField1" runat="server" />  

<asp:Button ID="btnInsert" Text="Insert Text" CssClass="button" runat="server" />
 
 I have registered the click event on pageload

protected void Page_Load(object sender, EventArgs  e) 
{
HiddenField1.Value = Guid.NewGuid().ToString();
btnInsert.Attributes.Add("onClick", "Show()");
 }

When I run this page it give me error

"Object required"
Object required FormBuilder.aspx, line 644 character 29


Please help me

Perhaps this question suits better to ASP.net forum :-)

By use of HTML and JavaScript it is very easy:

<input type="text" .... ><input type="button" value="reset text box" onClick="this.previousSibling.value='default value'">

Jan

I have posted it onto Asp.net forum. But did not got reply even single one yet.

since u r using server control(btnInsert) u have to register client event for that ,but what u r trying to do is going for a server side event;that is that show() will be executed only at server side and not on client side;and there is no metod with show() on server side from u r code thatz y itz saying object expected ;try to using a html button for that having runat server and register onclicl for tatit will work

I also get "Object Required" error when using IE (all IEs). No error when using FF. I am using WebFXTabPane JS and always get error on line 62 or 63. Below is the excerption for line 62 and 63:

}; WebFXTabPane.prototype.getSelectedIndex = function () { return this.selectedIndex;}; WebFXTabPane.prototype.addTabPage = function ( oElement ) { if ( !hasSupport() ) return; if ( oElement.tabPage == this )

return oElement.tabPage; var n = this.pages.length; var tp = this.pages[n] = new WebFXTabPage( oElement, this, n ); tp.tabPane = this; this.tabRow.appendChild( tp.tab ); if ( n == this.selectedIndex )

Thank you in advance for any help.

Jay

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.