Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How to capture click event of tab???How to capture click event of tab???
Previous
 
Next
New Post
10/14/2008 3:07 AM
 

Hi All,

I have a grid which populates the records depending on the dropdown list selection. The dropdownlist and the grid are associated with the same TAB/Page.

At first time while getiing in to the Tab I need to set the value for that dropdown as 0, but later point it should be ratained till I leave that page/Tab.But once I leave that Tab dropdow must be set as 0.

To do this if I am using session then the value will be retained though I go to another tab and come back. If I use view state then for every dropdown selection it will go to page load and the selected value can not be retained since page load I am setting the value for the dropdown as o (even the pagination control will postback the page for every paging event)

Is there any way to capture on click event or event which fires while leaving the tab so that I can nulify the session at the place.

If there is any other way to do the same please do let  me know

Thanks,

Kirti

 
New Post
10/19/2008 8:18 AM
 

Why not wrap the assignement in a if (!Page.isPostBack) {... assignement... } routine. THis will only fire if you refresh the page or go to the page the first time. On page postbacks it will skip this and the v13wstat3 will fill in the last value. If this is not an option you could also do something like:

int idx = lstname.SelectedIndex;

...assignement....

lstname.SelectedIndex = idx;

 

 
New Post
10/20/2008 3:08 AM
 

Hi,

Thanks for teh reply but I can not use (!Page.isPostBack) becuase every time when I select the page from paging control it refresh the page and will be treated as fresh page. Which is why I am using Session to retain the value.

int idx = lstname.SelectedIndex;

I am using the above syntax and storing the same in session. now the problem is this session value must nullitfy when I am out of this page I mean I go to another page and come back to this again.This time I would like to have the index as default one ( which is 0), but I will get the one which is stored in session.

The question is how to nullify session while leaving the page or while entering the page very  at first time? This could be done using click event on the tab , but I donot know the place where I can capture this event?

 
New Post
10/22/2008 4:11 AM
 

Hi,

I see a few options:

1) use a cookie (works better for me, could also be done with session of course) to store the value and build every link you have in the page to include something like "postedback=true" in the querystring, look for that on page load and if it is not there reset the cookie.

2) if it is only the pagination that causes this change your pagination to use postbacks. I built a simple custom pagination control (did this because the normal pagination would not use postbacks but navigateurl leading to this exact problem). It looks a bit like this (is more complicated here because this source resides in a controll that is loaded in runtime through loadcontrol):

ascx file:
<asp:Repeater id="lstContentProduct" runat="server" Visible="true">
    etc....
</asp:Repeater>
<asp:PlaceHolder ID="pagingControl" runat="server" Visible="false" >
<asp:HiddenField ID="HiddenCurrentPage" runat="server" />
 <table width="100%">
            <tr>
                <td width="50%" align="left" valign="top">
                <asp:PlaceHolder ID="plhPageOf" runat="server" />
                </td>
                <td width="50%" align="right" valign="top">
                <asp:PlaceHolder ID="plhPageNums" runat="server" />
                </td>
            </tr>
       
        </table>
</asp:PlaceHolder>


Code behind:
.....
protected int CurrentPage = 1;
protected int TotalPages = -1;
protected int PageSize = 10;
private int _CurrentPage = -1;
.....

protected void pagingClicked(Object sender, CommandEventArgs e)
{
    CartasticProductController CPC = new CartasticProductController();
    switch (e.CommandName)
    {
        case "dopaging":
            _CurrentPage = Convert.ToInt32(e.CommandArgument.ToString());
            HiddenCurrentPage.Value = e.CommandArgument.ToString();
            updateRepeater();
            break;
    }
}
.....

private void updateRepeater()
{
YourController CPC = new YourController(); // use your own controller here
List<YourInfo> CPI = CPC.GetSometyhing(); // and hre your own info class
PagedDataSource lstContent = new PagedDataSource();
lstContent.DataSource = CPI;
if (_CurrentPage > 0)
{
    CurrentPage = _CurrentPage;
}
if (lstContent.PageSize > 0)
{
    lstContent.PageSize = PageSize;
    lstContent.CurrentPageIndex = CurrentPage - 1;
    lstContent.AllowPaging = true;
}
lstContentProduct.DataSource = lstContent;
lstContentProduct.DataBind();
if (PageSize == 0 || CPI.Count <= PageSize)
{
    pagingControl.Visible = false;
}
else
{
    pagingControl.Visible = true;
    plhPageNums.Controls.Clear();
    plhPageOf.Controls.Clear();

    TotalPages = CPI.Count/PageSize;
    Label lblPageOf = new Label();
    lblPageOf.ID = "lblPageOf";
    lblPageOf.CssClass = "Normal";
    lblPageOf.Text = Localization.GetString("pagePage.Text", this.LocalResourceFile);
    lblPageOf.Text += "&nbsp;" + CurrentPage + "&nbsp;";
    lblPageOf.Text += Localization.GetString("pageOf.Text", this.LocalResourceFile);
    lblPageOf.Text += "&nbsp;" + TotalPages + "&nbsp;";
    plhPageOf.Controls.Add(lblPageOf);

int PageNr = 1;
if (CurrentPage>1 && TotalPages>1)
{
 LinkButton hlNumLink = new LinkButton();
        hlNumLink.ID = "Paging_Prev";
        hlNumLink.CssClass = "Normal";
        hlNumLink.Text = Localization.GetString("pagePrev.Text", this.LocalResourceFile)+"&nbsp;";
        hlNumLink.CommandName = "dopaging";
        hlNumLink.CommandArgument = Convert.ToString(CurrentPage - 1); ;
        hlNumLink.Command += new CommandEventHandler(pagingClicked);
        plhPageNums.Controls.Add(hlNumLink);
}
    while (PageNr <= TotalPages)
    {
        if (!(PageNr == CurrentPage))
        {
            LinkButton hlNumLink = new LinkButton();
            hlNumLink.ID = "Paging_" + PageNr.ToString();
            hlNumLink.CssClass = "Normal";
            hlNumLink.Text = PageNr.ToString() + "&nbsp;";
            hlNumLink.CommandName = "dopaging";
            hlNumLink.CommandArgument = PageNr.ToString();
            hlNumLink.Command += new CommandEventHandler(pagingClicked);
            plhPageNums.Controls.Add(hlNumLink);
        }
        else
        {
            Label hlNumLink = new Label();
            hlNumLink.ID = "Paging_" + PageNr.ToString();
            hlNumLink.CssClass = "Normal";
            hlNumLink.Text = PageNr.ToString() + "&nbsp;";
            plhPageNums.Controls.Add(hlNumLink);
        }
        PageNr = PageNr + 1;
    }
    if (CurrentPage < TotalPages)
    {
        LinkButton hlNumLink = new LinkButton();
        hlNumLink.ID = "Paging_Next";
        hlNumLink.CssClass = "Normal";
        hlNumLink.Text = Localization.GetString("pageNext.Text", this.LocalResourceFile);
        hlNumLink.CommandName = "dopaging";
        hlNumLink.CommandArgument = Convert.ToString(CurrentPage + 1);
        hlNumLink.Command += new CommandEventHandler(pagingClicked);
        plhPageNums.Controls.Add(hlNumLink);
    }
}

 HTH

Alexander

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How to capture click event of tab???How to capture click event of tab???


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out