473,321 Members | 1,748 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,321 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 1176
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.