This is a migrated thread and some comments may be shown as answers.

Tabstrip/Multipage First Visit Issue...

3 Answers 107 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Mike Trank
Top achievements
Rank 1
Mike Trank asked on 17 Jun 2009, 06:29 PM
Hi. First off, thank you for taking the time to read this/help me.

I've designed a website/system that use the latest telerik controls.

I have a page that contains a tabstrip and a multipage.

I dynamically populate the tabstrip and multipage via VB code from an SQL DB/Table.

I have many user control pages (.ascx) that are added to the multipage via code and the multipage's PageViewCreated event.  

For this question's purpose, lets call each tab Tab1, Tab2, etc. and each user control page Tab1.ascx, Tab2.ascx, etc.

In each user control .ascx page, I have a page_load event that executes a global "TextFill()" function that finds all Label controls on the user control page and sets the .text, .font, etc. properties from an SQL database table.  The function's argument is of type UserControl so is called with Me (i.e. TextFill(Me) ), this is how it knows what label controls to find, lookup and populate.

Hope this all makes sense so far.

This process works fine but NOT for the first visit to the web app  (The first/default view of the tabstrip/multipage.).

I.e. the first time you go to my custom app, the tabstrip is dynamically populated and defaults to Tab1 selected with Tab1.ascx showing as the sub-content.  The sub-content does not have the properties applied from the global TextFill() function.

If I click to Tab2, it now works.  Tab2 sub-content has the labels all updated from the TextFill() function.

Then if I click back to Tab1, THAT one now works (the labels are all updated).

How can I make that TextFill() function in the user control page's Load event fire when the tabstrip/multipage is FIRST dynamically populated/viewed ?

I tried putting the TextFill() function in different events of the user control page (i.e. PreRender, etc.). but no luck.

If I could just get that Tab1.ascx to force update or load again after the first visit to the site.

Any ideas?

Again, I hope I explained all of this good enough.

Thank you very much.

3 Answers, 1 is accepted

Sort by
0
Alex Lawson
Top achievements
Rank 1
answered on 18 Jun 2009, 09:34 AM
I have a similar app (dynamically loaded tabs at page load, etc) but it does not use ascx controls but div\iframes - so my solution may not be applicable...but...

After dynamically loading the tabs from the database, I call a javascript method via c# as follows:

 
string strScript = "<script language=\"Javascript\">" + Environment.NewLine + 
        "ViewProcess(" + rtsView.Tabs[0].Value + ",'--')" + Environment.NewLine + 
        "</script>\n"
Page.RegisterStartupScript("key", strScript); 

Which in turn initiates the content of the page, generating a natural postback.  I wonder if in your case simply selecting the tab via javascript would kick off your page load method?


0
Mike Trank
Top achievements
Rank 1
answered on 18 Jun 2009, 07:42 PM

Hi, Thanks for your reply.

I did try some techniques based on what you mentioned, but couldn't get them to work right.  You did lead me on to another idea...

I used some javascript and a hidden button...

in .ascx...

 

 

<script type="text/javascript">

 

    function ClickIt()

    {

    var ButtonId = '<%= btnHidden.ClientID %>';

    var HiddenButton = document.getElementById(ButtonId);

    HiddenButton.click();

    }

</script>

 

<div style="display:none">

    <asp:Button ID="btnHidden" runat="server" Text="blah" UseSubmitBehavior="false" />

</div>

in .ascx.vb in page_load event...

If Session("FirstLoad") = True Then

 

 

    Session("FirstLoad") = False

 

 

    ScriptManager.RegisterStartupScript(Me.Parent.Page, Me.Parent.Page.GetType, "refreshit", "ClickIt();", True)

 

 

End If


This has been working fine so far.  Didn't in firefox at first then searched the web and had to use the UseSubmitBehavior="false" for whatever reason.

Ok Thanks again I appreciate it!


 

0
Alex Lawson
Top achievements
Rank 1
answered on 19 Jun 2009, 08:23 AM
No problem, glad you found a solution
Tags
TabStrip
Asked by
Mike Trank
Top achievements
Rank 1
Answers by
Alex Lawson
Top achievements
Rank 1
Mike Trank
Top achievements
Rank 1
Share this question
or