Showing posts with label ascx. Show all posts
Showing posts with label ascx. Show all posts

Saturday, March 31, 2012

Subscribing to event from Template Column

I have an ascx control in the ItemTemplate of a Template Column in a
datagrid. The control (myControl) raises an event.

I'm trying to figure out how I can subscribe to the event. It can't be done
at design time because myControl is not one of the recognized controls. At
run time I would expect to use AddHandler but I can't seem to reference
myControl.

How can I subscribe to the event?

Thanks,
THi Tina,

If your control is simply a composite control that is placed declaratively
on the page at design time then you can add the event handler within the ascx
codebehind file.

Alternatively, you can use event delegates to expose events out of your ascx
to its NamingContainer (in your case it is the DataGridItem) as I did in this
example: http://www.societopia.net/Samples/D...tDelegates.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com

"Tina" wrote:

> I have an ascx control in the ItemTemplate of a Template Column in a
> datagrid. The control (myControl) raises an event.
> I'm trying to figure out how I can subscribe to the event. It can't be done
> at design time because myControl is not one of the recognized controls. At
> run time I would expect to use AddHandler but I can't seem to reference
> myControl.
> How can I subscribe to the event?
> Thanks,
> T
>
I guess I'm going to have to learn c# if for nothing other than to follow
the examples...

in VB to handle an event we ....
AddHandler myControl.TimerEvent, AddressOf me.HandleTimerEvent
..
..
Protected Sub HandleTimerEvent(byval o as Object, byval e as TimerArgs)
.. code to handle event is here...
end sub

How would the AddHandler code look in the case where myControl is in
DataGrid1?

"Phillip Williams" <Phillip.Williams@.webswapp.com> wrote in message
news:0EF5A6EE-2CBF-4FDE-9B9F-148297D8E8CA@.microsoft.com...
> Hi Tina,
> If your control is simply a composite control that is placed declaratively
> on the page at design time then you can add the event handler within the
> ascx
> codebehind file.
> Alternatively, you can use event delegates to expose events out of your
> ascx
> to its NamingContainer (in your case it is the DataGridItem) as I did in
> this
> example: http://www.societopia.net/Samples/D...tDelegates.aspx
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
> "Tina" wrote:
>> I have an ascx control in the ItemTemplate of a Template Column in a
>> datagrid. The control (myControl) raises an event.
>>
>> I'm trying to figure out how I can subscribe to the event. It can't be
>> done
>> at design time because myControl is not one of the recognized controls.
>> At
>> run time I would expect to use AddHandler but I can't seem to reference
>> myControl.
>>
>> How can I subscribe to the event?
>>
>> Thanks,
>> T
>>
>>
>
Hi Tina,

For you to be able to handle an event (e.g. TimerEvent) raised by your
control it has to define a delegate method that you can use when placing that
control in the DataGrid. If it does that then you can handle that event by
specifying a function for the delegate method (e.g. if your event is named
TimerEvent, you should design your control to expose a method named
OnTimerEvent)

I created here
http://www.societopia.net/Samples/D...rolsEvents.aspx a sample
in VB.Net where I designed a user control (in an ascx file) that raises an
event (I called it CustomEvent1) by exposing a delegate method called
"OnCustomEvent1". I then included that control in a TemplateColumn on the
DataGrid and wired the delegate function named OnCustomEvents to an event
handler within the page class codebehind.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com

"Tina" wrote:

> I guess I'm going to have to learn c# if for nothing other than to follow
> the examples...
> in VB to handle an event we ....
> AddHandler myControl.TimerEvent, AddressOf me.HandleTimerEvent
> ..
> ..
> Protected Sub HandleTimerEvent(byval o as Object, byval e as TimerArgs)
> .. code to handle event is here...
> end sub
> How would the AddHandler code look in the case where myControl is in
> DataGrid1?
> "Phillip Williams" <Phillip.Williams@.webswapp.com> wrote in message
> news:0EF5A6EE-2CBF-4FDE-9B9F-148297D8E8CA@.microsoft.com...
> > Hi Tina,
> > If your control is simply a composite control that is placed declaratively
> > on the page at design time then you can add the event handler within the
> > ascx
> > codebehind file.
> > Alternatively, you can use event delegates to expose events out of your
> > ascx
> > to its NamingContainer (in your case it is the DataGridItem) as I did in
> > this
> > example: http://www.societopia.net/Samples/D...tDelegates.aspx
> > --
> > HTH,
> > Phillip Williams
> > http://www.societopia.net
> > http://www.webswapp.com
> > "Tina" wrote:
> >> I have an ascx control in the ItemTemplate of a Template Column in a
> >> datagrid. The control (myControl) raises an event.
> >>
> >> I'm trying to figure out how I can subscribe to the event. It can't be
> >> done
> >> at design time because myControl is not one of the recognized controls.
> >> At
> >> run time I would expect to use AddHandler but I can't seem to reference
> >> myControl.
> >>
> >> How can I subscribe to the event?
> >>
> >> Thanks,
> >> T
> >>
> >>
> >>
>

Subscribing to event from Template Column

I have an ascx control in the ItemTemplate of a Template Column in a
datagrid. The control (myControl) raises an event.
I'm trying to figure out how I can subscribe to the event. It can't be done
at design time because myControl is not one of the recognized controls. At
run time I would expect to use AddHandler but I can't seem to reference
myControl.
How can I subscribe to the event?
Thanks,
THi Tina,
If your control is simply a composite control that is placed declaratively
on the page at design time then you can add the event handler within the asc
x
codebehind file.
Alternatively, you can use event delegates to expose events out of your ascx
to its NamingContainer (in your case it is the DataGridItem) as I did in thi
s
example: http://www.societopia.net/Samples/D...tDelegates.aspx
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Tina" wrote:

> I have an ascx control in the ItemTemplate of a Template Column in a
> datagrid. The control (myControl) raises an event.
> I'm trying to figure out how I can subscribe to the event. It can't be do
ne
> at design time because myControl is not one of the recognized controls. A
t
> run time I would expect to use AddHandler but I can't seem to reference
> myControl.
> How can I subscribe to the event?
> Thanks,
> T
>
>
I guess I'm going to have to learn c# if for nothing other than to follow
the examples...
in VB to handle an event we ....
AddHandler myControl.TimerEvent, AddressOf me.HandleTimerEvent
.
.
Protected Sub HandleTimerEvent(byval o as Object, byval e as TimerArgs)
. code to handle event is here...
end sub
How would the AddHandler code look in the case where myControl is in
DataGrid1?
"Phillip Williams" <Phillip.Williams@.webswapp.com> wrote in message
news:0EF5A6EE-2CBF-4FDE-9B9F-148297D8E8CA@.microsoft.com...
> Hi Tina,
> If your control is simply a composite control that is placed declaratively
> on the page at design time then you can add the event handler within the
> ascx
> codebehind file.
> Alternatively, you can use event delegates to expose events out of your
> ascx
> to its NamingContainer (in your case it is the DataGridItem) as I did in
> this
> example: http://www.societopia.net/Samples/D...tDelegates.aspx
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
> "Tina" wrote:
>
Hi Tina,
For you to be able to handle an event (e.g. TimerEvent) raised by your
control it has to define a delegate method that you can use when placing tha
t
control in the DataGrid. If it does that then you can handle that event by
specifying a function for the delegate method (e.g. if your event is named
TimerEvent, you should design your control to expose a method named
OnTimerEvent)
I created here
http://www.societopia.net/Samples/D...rolsEvents.aspx a sampl
e
in VB.Net where I designed a user control (in an ascx file) that raises an
event (I called it CustomEvent1) by exposing a delegate method called
“OnCustomEvent1”. I then included that control in a TemplateColumn on t
he
DataGrid and wired the delegate function named OnCustomEvents to an event
handler within the page class codebehind.
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Tina" wrote:

> I guess I'm going to have to learn c# if for nothing other than to follow
> the examples...
> in VB to handle an event we ....
> AddHandler myControl.TimerEvent, AddressOf me.HandleTimerEvent
> ..
> ..
> Protected Sub HandleTimerEvent(byval o as Object, byval e as TimerArgs)
> .. code to handle event is here...
> end sub
> How would the AddHandler code look in the case where myControl is in
> DataGrid1?
> "Phillip Williams" <Phillip.Williams@.webswapp.com> wrote in message
> news:0EF5A6EE-2CBF-4FDE-9B9F-148297D8E8CA@.microsoft.com...
>
>

Monday, March 26, 2012

Suggestion regarding Top/footer includes

Hello,

I have the following situation. On all of my pages I would like to include a top and footer ascx file. Therefore I created two user controls. Now the the top.ascx contains another usercontrol which is a menu and shown in a table and each link in that menu is seperated with a line break. Somethin like this:

link1
link2
link3
...

Now this menu is in a table. The table looks like this:

<table width="100%">
<tbody>
<tr valign="top">
<td width="15%">
MENU HERE
</td>
<td>
CONTENT WILL BE HERE
</td>
</tr>
</tbody>
</table
Now I need to get rid of everything what comes after the MENU HERE <TD>, because this will be used for my main content. and the table will be closed then in the footer. However webmatrix always adds the missing html tags and therefore my table always looks like shown above. I hope that you guys understand what I mean. Is there anything I can do or is this is the wrong way?

ThanksI recommend that you use MasterPages, where you place the footer/header in that template.

Regards.
Arent MasterPages only in 2.0? I am using 1.1.
Nop, try to download this forum code and see how master pages are being used.

regards.
Thanks haider_balal,

I can imagine that the code for this forum is complicated and that it contains a lot of stuff. Isnt there an easier article which explains master pages in 1.1?
Hello, try to check this and give me your opinion:

MasterPages Templating Framework

regards.
2.0 will be so much fun
Why wait till asp.net 2.0 ? We can still use it in 1.1 !!!!!

regards.

Saturday, March 24, 2012

Super weird problem

I have a really strange problem. I've implemented a website using a lot of user controls (ascx). Everything worked fine before, and it has run for months.

And today, suddenly all those user controls (scrolling messages, tabstrips, menu, etc) don't work anymore, i.e. nothing appears although there's no error message. And I do not change anything, the codes remain exactly the same as before.

The web controls (textBox, calendar, buttons, etc) on the main page (not in ascx) still work fine.

I've spent, in vain, a lot of hours trying to figure it out. Do you have an idea what's going wrong ? I really appreciate your help.

Thanks

Btw, the codes are quite long, so I won't post it here. But if you need to see a part of it, just let me know, I'll post it.> nothing appears although there's no error message.

What exactly do you mean, "nothing appears"? If you View > Source, what do you see? Have the ASCX controls not be added at all? Or have they been added but not rendered?

Also, the elements you mention as having ceased to work look as though they'd use Javascript. Even if you haven't changed the ASCX or ASPX files, have you perhaps changed an external javascript file? I once forgot to add ";" to the end of a new line of script ... and it broke myentire site!
Things always get broken when no one has changed anything :)

If truly nothing has changed, try resetting IIS, as something might be confused in there...

Most likely though, as SomeNewKid2 said, it might be possible you made a change to something and didn't think it would even affect the controls...

But I could be wrong too :)
If the site is being hosted, I would check with the hosting site that they haven't upgraded the .net framework to 1.1.