473,386 Members | 1,908 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,386 software developers and data experts.

running javascript function on a webcontrol

hi all,
i am working on a website using asp.net-vb.net
i am using a textbox(web control) and want to run javascript function
as the text in the textbox is changed. but as soon as i run the page
in the browser i get the foll. message:

Compiler Error Message: BC30456: 'func' is not a member of
'ASP.frmMaster_aspx'.
where func is name of the function
<asp:textbox id="txtDetails" runat="server"
OnTextChanged="func()"></asp:textbox>

i have gone thro' the problem and have found that being a web control
the compiler finds it a problem, that which function is to be run
while executing the code. the function asp.net provides in its
framework or the one i have written in the script and that's why it
gives the error.

now there is a perfect syntax which is to be used at the code-behind
at the pageload. i have tried a few but was unsuccessful. please tell
me what is to be written in the HTML of teh page and at the
codebehind(vb.net)
please help.
Nov 19 '05 #1
2 5986
You have to do this using the *client-side* event, not the server-side
event. So, in your user control, use the following:

Private Sub Page_Load _
(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
TextBox1.Attributes.Add("onchange", "alert('changed');")
End Sub

When you add this to the .aspx page it will render like this:

<input name="Txtusr1:TextBox1" type="text" id="Txtusr1_TextBox1"
onchange="alert('changed');" />

Ken
Microsoft MVP [ASP.NET]
Toronto

"hemant" <he********@yahoo.com> wrote in message
news:1b**************************@posting.google.c om...
hi all,
i am working on a website using asp.net-vb.net
i am using a textbox(web control) and want to run javascript function
as the text in the textbox is changed. but as soon as i run the page
in the browser i get the foll. message:

Compiler Error Message: BC30456: 'func' is not a member of
'ASP.frmMaster_aspx'.
where func is name of the function
<asp:textbox id="txtDetails" runat="server"
OnTextChanged="func()"></asp:textbox>

i have gone thro' the problem and have found that being a web control
the compiler finds it a problem, that which function is to be run
while executing the code. the function asp.net provides in its
framework or the one i have written in the script and that's why it
gives the error.

now there is a perfect syntax which is to be used at the code-behind
at the pageload. i have tried a few but was unsuccessful. please tell
me what is to be written in the HTML of teh page and at the
codebehind(vb.net)
please help.


Nov 19 '05 #2
Another solution is to use client control, instead of server control:
<input type="text" onchange="func();">

Hope this helps!
Regards,
Kostadin Kostov

"hemant" wrote:
hi all,
i am working on a website using asp.net-vb.net
i am using a textbox(web control) and want to run javascript function
as the text in the textbox is changed. but as soon as i run the page
in the browser i get the foll. message:

Compiler Error Message: BC30456: 'func' is not a member of
'ASP.frmMaster_aspx'.
where func is name of the function
<asp:textbox id="txtDetails" runat="server"
OnTextChanged="func()"></asp:textbox>

i have gone thro' the problem and have found that being a web control
the compiler finds it a problem, that which function is to be run
while executing the code. the function asp.net provides in its
framework or the one i have written in the script and that's why it
gives the error.

now there is a perfect syntax which is to be used at the code-behind
at the pageload. i have tried a few but was unsuccessful. please tell
me what is to be written in the HTML of teh page and at the
codebehind(vb.net)
please help.

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jon | last post by:
I would like to pass a reference of a webcontrol into a javascript function. Below I have a snippet of code. "me.selectedValue" returns undefined. I was hoping that would return the value that...
7
by: walter | last post by:
Here is my case : I create a user control which contains One checkbox control to enable/disable the other two textbox control. I'm using server control instead of HTML control, and I don't want to...
2
by: Peregrin | last post by:
Hello world. I will try to explain my problem. I've a webcontrol with an interface which provides a choice of methods. After including the webcontrol in a special aspx page, I want to call an...
1
by: daniel_xi | last post by:
Hi all, I am running a VS 2003 .NET project on my client machine (Win 2000 SP4, ..NET framework 1.1), running an ASP.NET application on a remote web server (Win 2000 Server, IIS 6.0, .NET...
1
by: Larry | last post by:
Anyone have an example of a webuser control with a checkbox that passes information to a JavaScript function on the same page? on the page I have a checkbox and a textbox (both are server...
3
by: Aamir Ghanchi | last post by:
Hi, I am wondering why the <%= % is not working when I use it to pass the clientid to a javascrip function from the aspx declaration code. Say, I have a listbox webcontrol and from its...
1
by: timor.super | last post by:
Hi group, what I would like to do is maybe a little hard and I can't achieve to make it. So I need your help to go in the right way. What I want is to create a webcontrol that can use one its...
3
by: jeroen.bolle | last post by:
I'm designing a form where the user can decide how many options for a poll he wants to add. There's a "+" button to dynamically add textboxes with javascript, without a postback. How do I access...
18
by: Dan | last post by:
Hi, There is a detailsview which contains a textbox in editmode. How to get the id of the textbox in javascript? I tried this: <asp:DetailsView ID="DetailsView1" runat="server" >...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...

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.