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

Problem With User Control

Hi,

I have created a user control in C#,and using it in one of my webpages.

Now, i want to do something like this:

call a function from user control(dll), but which is implemented in
the webpage's .cs or webpage's javascript(events).
Something like event handling.

Note: I wanted to create an ActiveX Control, i found out that user
control are used instead in .net.

Any suggestions on how to do it?

Bye.

Nov 19 '05 #1
5 1180
Do just that - implement event handling in your control.

type "event" anywhere in the code, press F1 and read the example.

"batista" wrote:
Hi,

I have created a user control in C#,and using it in one of my webpages.

Now, i want to do something like this:

call a function from user control(dll), but which is implemented in
the webpage's .cs or webpage's javascript(events).
Something like event handling.

Note: I wanted to create an ActiveX Control, i found out that user
control are used instead in .net.

Any suggestions on how to do it?

Bye.

Nov 19 '05 #2
thnks for reply.

i did that.

sort of pseudo code

class A
{
public delegate void aa();
public static event aa aaevent;

public func()
{
aaevent(); //i'm getting an exception here that object is set to
null.
}

}

now i used this dll in my webpage with object tag.

then i wrote this in javascript:

<SCRIPT lang="javascript">
function CallIt() //this is called on button click
{
var objAct = document.getElementById"myclassA");
objAct.func();
}

</SCRIPT>

<SCRIPT lang="javascript" event="aaevent()" for="myclassA">

alert("It is the Event of ActX Control");
</SCRIPT>

So why is it happening?

Nov 19 '05 #3
i 'm getting the exception of null reference. when i run my webpage

Nov 19 '05 #4
batista,

Why do you need static event in an instance User control?

and unless the client (your web page that uses the control) has hooked up to
the event, your event reference will be null, so you will have to check it in
your code before calling the event:

if (aaaevent != null)
aaevent();

HTH
"batista" wrote:
thnks for reply.

i did that.

sort of pseudo code

class A
{
public delegate void aa();
public static event aa aaevent;

public func()
{
aaevent(); //i'm getting an exception here that object is set to
null.
}

}

now i used this dll in my webpage with object tag.

then i wrote this in javascript:

<SCRIPT lang="javascript">
function CallIt() //this is called on button click
{
var objAct = document.getElementById"myclassA");
objAct.func();
}

</SCRIPT>

<SCRIPT lang="javascript" event="aaevent()" for="myclassA">

alert("It is the Event of ActX Control");
</SCRIPT>

So why is it happening?

Nov 19 '05 #5
batista,

my bad - should have read the whole message. I am not sure whether you can
hookup to the SERVER user controls from the CLIENT-side script. My
understanding is that you cannot do that (I may be wrong though).

As I have never done anything like that - you may need to re-post your
question so that others may be able to help you. When you do that, try to
soecify exactly what you need - or what you are trying to achieve.

"batista" wrote:
thnks for reply.

i did that.

sort of pseudo code

class A
{
public delegate void aa();
public static event aa aaevent;

public func()
{
aaevent(); //i'm getting an exception here that object is set to
null.
}

}

now i used this dll in my webpage with object tag.

then i wrote this in javascript:

<SCRIPT lang="javascript">
function CallIt() //this is called on button click
{
var objAct = document.getElementById"myclassA");
objAct.func();
}

</SCRIPT>

<SCRIPT lang="javascript" event="aaevent()" for="myclassA">

alert("It is the Event of ActX Control");
</SCRIPT>

So why is it happening?

Nov 19 '05 #6

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

Similar topics

0
by: Marko | last post by:
Please, can anyone help me... I have problem with VisualStudio.NET instalation: First step is OK (framework...), but when instalation of .NET begin, after some time I get message "INSTALATION...
1
by: Rhy Mednick | last post by:
I'm creating a custom control (inherited from UserControl) that is displayed by other controls on the form. I would like for the control to disappear when the user clicks outside my control the...
5
by: | last post by:
Hi, I'm trying to use the cookie munging session handling behaviour of asp.net instead of cookies themselves as I'm finding quite a few people are barring cookies (especially AOL users). If I...
7
by: Tim T | last post by:
Hi, I have the need to use dynamically loaded user controls in a webform page. I have the controls loading dynamically, and that part works fine. this is the code used in a webform to dynamically...
1
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am have facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the...
1
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the web...
9
by: Anders K. Jacobsen [DK] | last post by:
Hi I have this that adds some usercontrol (UCTodays.ascx) to a placeholder foreach(A a in B){ UCTodays ucline = (UCTodays )LoadControl("UCTodays.ascx");...
1
by: Steve Booth | last post by:
I have a web form containing a button that when selected adds a user control to a place holder. The user control contains a button. The first time the user control is added the contained button...
5
by: Segfahlt | last post by:
I need a little help here please. I have 2 win forms user controls in 2 different projects that I'm hosting in 2 different virtual directories. The controls have been test and operate okay in...
1
by: Jeff | last post by:
Hey ..NET 2.0 I've created a User Control which contain a DataGridView. This User Control is displayed on a TabPage. This TabPage is added to the TabControl during runtime. The problem is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.