RaisePostBackEvent Question

G

Guest

In my page load, I have the following

DropDownList.Attributes.Add ("onblur", Page.GetPostBackEventReference(this, "Update"))

The page itself implements IPostBackEventHandler (I don't want a custom control) as

#region IPostBackEventHandler Member
public void RaisePostBackEvent(string eventArgument

if (eventArgument == "Update"

//doing stuff here



#endregio

When I move the focus off of the DropDownList, the page does postback, but RaisePostBackEvent isn't called

Why would this be

TI

jdn
 
C

Cowboy

The norm, with a drop down, is something like so:

ASPX page
-------------
<asp:DropDownList id="ddlFindServiceCategories" runat="server"
Visible="False" />


Code Behind:
--------------
//event handler wiring
this.ddlFindServiceCategories.SelectedIndexChanged += new
System.EventHandler(this.ddlFindServiceCategories_SelectedIndexChanged);

private void ddlFindServiceCategories_SelectedIndexChanged(object sender,
System.EventArgs e)
{
//Code here for event
}


This is the easiest way to set up events.

I notice that you are trying to use a custom handler. Most likely you are
missing the wire that fires the event (don't have time to really examine
your code right now, apologies).

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
jdn said:
In my page load, I have the following:

DropDownList.Attributes.Add ("onblur",
Page.GetPostBackEventReference(this, "Update"));
The page itself implements IPostBackEventHandler (I don't want a custom control) as:

#region IPostBackEventHandler Members
public void RaisePostBackEvent(string eventArgument)
{
if (eventArgument == "Update")
{
//doing stuff here;
}
}

#endregion

When I move the focus off of the DropDownList, the page does postback, but
RaisePostBackEvent isn't called.
 
K

Kevin Spencer

Did you give the Control a Name attribute that corresponds to its UniqueID?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

jdn said:
Thanks but that isn't what I want to do here for various reasons
(including that I implement some javascript so that the dropdownlist does
autocomplete when typing, and i don't need SelectedIndexChanged firing every
key press).
 
G

Guest

Yes, I did. As I mentioned, the onblur works (if I have the focus on the dropdownlist, and then tab out, the page does post back)

Do I need to write an event handler in the

private void InitializeComponent() functio

to wire up the onBlur to the

public void RaisePostBackEvent(string eventArgument

and if so, what would it look like

TI
jd


----- Kevin Spencer wrote: ----

Did you give the Control a Name attribute that corresponds to its UniqueID

--
HTH
Kevin Spence
..Net Develope
Microsoft MV
Big things are made u
of lots of little things

jdn said:
Thanks but that isn't what I want to do here for various reason
(including that I implement some javascript so that the dropdownlist doe
autocomplete when typing, and i don't need SelectedIndexChanged firing ever
key press)
 
T

Teemu Keiski

Hi,

so you want to have this code at the Page? If I understand right, In that
case you'd override the RaisePostBackEvent method

protected override void RaisePostBackEvent(IPostBackEventHandler
sourceControl, string eventArgument)
{
if(eventArgument=="Update")
Response.Write("Do something...");
base.RaisePostBackEvent (sourceControl, eventArgument);
}

Page itself implementing IPostBackEventHandler isn't needed (as this
interface implementation is obeyed only with controls when their
RaisePostBackEvent is called, Page uses bit different mechanism as it is the
top-controller for postback data and so on)

-
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke


Yes, I did. As I mentioned, the onblur works (if I have the focus on the
dropdownlist, and then tab out, the page does post back).
 
G

Guest

I'm totally stymied. That code fires on all postbacks, except for the onblur one (Page_Load fires, but not RaisePostBackEvent)

I've tried variations on

myDropDownList.Attributes.Add ("onblur", Page.GetPostBackEventReference(myDropDownList, "Update"))
myDropDownList.Attributes.Add ("onblur", Page.GetPostBackEventReference(this, "Update"))

I've tried GetPostBackClientEvent. I've tried "onBlur" instead of "onblur." Nothing seems to work

Do I need an explicit wire anywhere? Am I missing a small javascript piece to do this

Any help would be greatly appreciated

jd

----- Teemu Keiski wrote: ----

Hi

so you want to have this code at the Page? If I understand right, In tha
case you'd override the RaisePostBackEvent metho

protected override void RaisePostBackEvent(IPostBackEventHandle
sourceControl, string eventArgument

if(eventArgument=="Update"
Response.Write("Do something...")
base.RaisePostBackEvent (sourceControl, eventArgument)


Page itself implementing IPostBackEventHandler isn't needed (as thi
interface implementation is obeyed only with controls when thei
RaisePostBackEvent is called, Page uses bit different mechanism as it is th
top-controller for postback data and so on


Teemu Keisk
MCP, Microsoft MVP (ASP.NET), AspInsiders membe
ASP.NET Forum Moderator, AspAlliance Columnis
http://blogs.aspadvice.com/jotek


Yes, I did. As I mentioned, the onblur works (if I have the focus on th
dropdownlist, and then tab out, the page does post back)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top