Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > call a javascript function within code behind

Reply
Thread Tools

call a javascript function within code behind

 
 
sajithkahawatta
Guest
Posts: n/a
 
      06-20-2007
i want to call a java script function from code behind.

in page1.aspx page i placed script'

<script language="javascript">
function SetSelected()
{
infoTextBox.select();
}
</script>

i want to highlight text in infotextbox in some cases. so i want to
call this function within code behind.(within if statment).
how can i call this function .i tried with RegisterClientScriptBlock()
but i could not do it .but i think it can be used. can u tell me how a
java script function is called.

thankx

 
Reply With Quote
 
 
 
 
Sriram Surapureddy
Guest
Posts: n/a
 
      06-20-2007
There are several ways to do it.One approach is add the javascript in hidden
field like this..
<asp:HiddenField ID="test" runat="server" />
<script type="text/javascript">
if(document.all["test"].value == "1")
{
//whtever the script
document.all["test"].value ="";
}
</script>

and in the if condition set the "test" field to 1.
Hope this helps.


"sajithkahawatta" wrote:

> i want to call a java script function from code behind.
>
> in page1.aspx page i placed script'
>
> <script language="javascript">
> function SetSelected()
> {
> infoTextBox.select();
> }
> </script>
>
> i want to highlight text in infotextbox in some cases. so i want to
> call this function within code behind.(within if statment).
> how can i call this function .i tried with RegisterClientScriptBlock()
> but i could not do it .but i think it can be used. can u tell me how a
> java script function is called.
>
> thankx
>
>

 
Reply With Quote
 
 
 
 
sajithkahawatta
Guest
Posts: n/a
 
      06-21-2007
thanx everyone for reply.
dear David R. Longnecker i used your code and it is
worked.
thanx again

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call javascript function from code behind verci ASP .Net 4 04-09-2007 06:19 AM
Non-code behind to code behind John ASP .Net 2 02-19-2007 07:08 PM
Call VB Code Behind Function from JavaScript??? jason.gyetko@epower-inc.com ASP .Net 5 06-30-2006 05:51 PM
Call a DLL LIB function in ASP.NET (Code Behind) or VB.NET (The same code is working fine in VB 6.0) Peri ASP .Net 2 07-20-2005 03:13 AM
Re: Code Behind vs. no code behind: error Ben Miller [msft] ASP .Net 1 06-28-2003 01:46 AM



Advertisments