Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Implementing postback functionality in custom control

Reply
Thread Tools

Implementing postback functionality in custom control

 
 
Showjumper
Guest
Posts: n/a
 
      03-05-2005
Here is my situation. I first made a custom composite control (consisting of
a textbox and button) that does a whois lookup based on the domain name
entered in the textbox. Getting the lookup sub to fire in the composite
version is not a problem b/c all i do is add AddHandler LookUp.Click,
AddressOf DoLookUp.

Now i have i attempted to make a rendered version of the control in which i
directly render the html for the textbox and button. I have been over the
documentation for the IPostBackDataHandler, IPostBackEventHandler interfaces
and their associated functions. I have also consulted my books on server
control building. All the examples i have seen show how to add postback
functionality to simple controls, i.e a custom button control for instance
which then has its event called from the codebehing of the aspx page. What i
want to do is add postback functioality to the control and then with that
call the dolookup sub. Can someone walk me thru? I can post code if needed.
Or if my explanation is not clear enoughi can explain further. How do i
trigger the sub in the custom control from the rendered button? I am using
vbnet BTW. The more detailed explanation the better since i have banging my
head against the wall for sometime (not literally tho'). Any and all help is
appreciated...



 
Reply With Quote
 
 
 
 
Showjumper
Guest
Posts: n/a
 
      03-06-2005
I think i actually got it. What i did was move the lookup code to the
raisepostbackevent such that
If eventArgument = "DoLookup" Then
'do the lookup
end if

And for the submit button
wr.AddAttribute("onclick", Page.GetPostBackEventReference(Me, "DoLookup"))

Can some one comment on doing this way? Is this right? Thx...

Ashok


 
Reply With Quote
 
 
 
 
Wilco Bauwer
Guest
Posts: n/a
 
      03-06-2005
Read http://wilcoding.xs4all.nl/Wilco/View.aspx?NewsID=144 instead. You
can also take a look at the source code of some of the web controls on
my website.

The way you get a postback event reference looks ok, but you should
also register your control as a control which handles postbacks, and
implement the correct interface for handling postbacks.

----
- Wilco Bauwer
Blog & Custom Controls @ http://wilcoding.xs4all.nl

 
Reply With Quote
 
Showjumper
Guest
Posts: n/a
 
      03-06-2005
> The way you get a postback event reference looks ok, but you should also
register your control as a control which handles postbacks, and implement
the correct interface for handling postbacks.

By this i assume you mean implementing IPostBackDataHandler,
IPostBackEventHandler. If that is the case i have done so. What i have is
this and the submit button with the onclick attribute and eventargument that
mentioned previously. Can you comment or someone else can? text is the
domain name entered into the textbox and this value is maintained across
postbacks and the lookup code fires. I just want to be sure i am doing this
right. I dont htink i need to do anything in raisepostdatachanged since the
textbox value doesnt change across postbacks. Thx Ashok

Public Function LoadPostData(ByVal PostDataKey As String, ByVal Values As
NameValueCollection) As Boolean _
Implements IPostBackDataHandler.LoadPostData
text = Values(Me.UniqueID)
Return True
End Function

Public Sub RaisePostDataChangedEvent() _
Implements IPostBackDataHandler.RaisePostDataChangedEvent
' Dont need to do anything here
End Sub


Public Sub RaisePostBackEvent(ByVal eventArgument As String) Implements
System.Web.UI.IPostBackEventHandler.RaisePostBackE vent
If eventArgument = "DoLookup" Then
'Do the lookup = lookup code fires
End If
End Sub


 
Reply With Quote
 
Wilco Bauwer
Guest
Posts: n/a
 
      03-06-2005
Sorry, I did not read your initial posting and assumed several things.

The way you are doing it looks about right. However, I would raise an
event, instead of handling the "event" yourself. You probably want to
handle that event outside your class (e.g. let the client of your
control do the stuff), unless it really is part of your control's
functionality...

----
- Wilco Bauwer
Blog & Custom Controls @ http://wilcoding.xs4all.nl

 
Reply With Quote
 
Showjumper
Guest
Posts: n/a
 
      03-06-2005
Appreciate your input. I think for now i will leave it the way it is for
now since the lookup is the crux of the control.
"Wilco Bauwer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Sorry, I did not read your initial posting and assumed several things.
>
> The way you are doing it looks about right. However, I would raise an
> event, instead of handling the "event" yourself. You probably want to
> handle that event outside your class (e.g. let the client of your
> control do the stuff), unless it really is part of your control's
> functionality...
>
> ----
> - Wilco Bauwer
> Blog & Custom Controls @ http://wilcoding.xs4all.nl
>



 
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
[AJAX] custom control implementing IScriptControl : no key events notification in firefox Patrick Ruzand ASP .Net Building Controls 5 03-15-2007 02:18 PM
Implementing print functionality in ASP.NET web application =?Utf-8?B?VmVyYQ==?= ASP .Net 4 10-22-2006 08:11 PM
Implementing columns collection in Data grid custom control Sundararajan ASP .Net Building Controls 1 03-29-2005 01:21 AM
Implementing IPostBackDataHandler in a custom web control with VB.NET Andrew Dawson ASP .Net Building Controls 1 08-12-2004 06:34 PM
ControlDesigner not invoked on custom control when control is rendered within another custom control Matt Sokol ASP .Net Building Controls 2 08-07-2003 07:13 AM



Advertisments