event are not fired for dropdownlist, Imagebutton

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
10/1/2009 4:26:56 AM
Gravatar
Total Posts 2

event are not fired for dropdownlist, Imagebutton

Hi,

I have downloaded the mojo portal build version  2.3.16.

I needed a custom feature module to be added into one of our page, so i created an user control (an ascx file), in which i have dragged Drop down list control onto the page,set its AutoPostBack property to true and on the  SelectedIndexChanged event of the same control i have write a simple code to change the selected index, i have notice a weird thing that on changing the index of the drop down list the page is posted back but the event  DropDownList1_SelectedIndexChanged is not executed.

The page is inheriting from the  SiteModuleControl class.

Sample Code.

 SampleDD.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SampleDD.ascx.cs" Inherits="WebStore.UI.WebStore.RRShopControls.SampleDD" %>

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"

onselectedindexchanged="DropDownList1_SelectedIndexChanged">

</asp:DropDownList>

 

 --------------------------------------------------------------------------------

SampleDD.ascx.cs

 using System;

using System.Collections;

using System.Configuration;

using System.Data;

using System.Linq;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Xml.Linq;

using WebStore.Business;

using mojoPortal.Web;

 

namespace WebStore.UI.WebStore.RRShopControls

{

public partial class SampleDD : SiteModuleControl

{

protected void Page_Load(object sender, EventArgs e)

{

if (!Page.IsPostBack)

{

DropDownList1.DataSource = MembershipSevice.GetCountries();

DropDownList1.DataTextField = "CountryName";

DropDownList1.DataValueField = "CountryID";

DropDownList1.DataBind();

}

}

 

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)

{

DropDownList1.SelectedIndex = 1;

}

}

}

 ----------------------------------------------------------------------------------------

 

 

10/1/2009 2:10:16 PM
Gravatar
Total Posts 18439

Re: event are not fired for dropdownlist, Imagebutton

Hi,

Maybe try adding Page.EnableViewstate = true; in page load.

You might also try setting AutoEventWireup=false and then adding override void OnInit and then wire up page load and your other events. See examples of this in included code in mojoportal as thats generally what I do.

I generally try to avoid postback in modules because it can affect other modules on a page, so you either end up needing to redirect to the same page after your postback logic runs or else wrap it in an UpdatePanel so it does an ajax postback instead.

Hope it helps,

Joe

10/5/2009 3:45:50 AM
Gravatar
Total Posts 2

Re: event are not fired for dropdownlist, Imagebutton

hi Joe,

Thanks for your reply.

Enabling the ViewState works for me. but yes it increases the page size because we have used heavy controls like Datalist and dropdown onto our page, is there any other workaround to resolve this issue.

regards,

Rohit

10/5/2009 7:42:58 AM
Gravatar
Total Posts 18439

Re: event are not fired for dropdownlist, Imagebutton

ViewState is required to fire events.

If you are not using any Events on the DataList, you can try setting EnableViewstate to false on the Datalist and it may reduce the amount of viewstate.

Hope it helps,

Joe

You must sign in to post in the forums. This thread is closed to new posts.