473,395 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

server controls inside asp:wizard, doesnt render jscript if step is not first..

I'm trying to use a server control inside a template wizard step, when I drop such server control in the first step of the wizard everything goes ok.
When I insert even a blank step previous to the step which contains the server control, the javasript code of the server control is not rendered at all, the page doesn't fail during load but until I go with mouse over an item of the grid for instance.
When I check the rendered HTML I can see no HTML, nor javascript events of this server control where rendered, neither the implementation nor calls to javascript, but even rarer what is there visible in the grid for ie, even the other components of the server control, are not in the "view source code" content.
I seems it was sent to the client, even showed, but truncated in some phase..

Thanks in advance for your comments,
Louis.
PD:
The server control consists of a gridview with custom navigation&information capabilities and javascript functions to highlight the selected grid items or highlight when mouse over event occurs.. (full tested outside asp:wizard)
Sep 30 '10 #1
4 3015
Frinavale
9,735 Expert Mod 8TB
It would really help if you posted the code that is responsible for generating and registering the JavaScript so that we can help you solve this problem.

Also, are you using an UpdatePanel along with the wizard?

-Frinny
Sep 30 '10 #2
Thanks a lot for your reply. Yes I'm using an UpdatePanel which contains the wizard.
PAGE CODE:
..
Expand|Select|Wrap|Line Numbers
  1. <asp:UpdatePanel ID="updatePanelWizard" runat="server" >
  2. <ContentTemplate> 
  3.   <asp:Wizard ID="wzdE" runat="server" ..
  4.     <SideBarTemplate> .. </SideBarTemplate>
  5.     <StepStyle .. />
  6.     <StepNavigationTemplate> .. </StepNavigationTemplate>
  7.     <WizardSteps>
  8.       <asp:TemplatedWizardStep ID="Step1" runat="server"..
  9.         <ContentTemplate>
  10.           <uc1:MyServerControl .. runat="server"/>
  11.         </ContentTemplate>
  12.         <CustomNavigationTemplate> ..
  13.         </CustomNavigationTemplate>
  14.       </asp:TemplatedWizardStep>
  15.       <asp:TemplatedWizardStep ID="Step2" runat="server"..
  16.         <ContentTemplate>
  17.           <!-- Server control (uc1) doesn't work here -->
  18.         </ContentTemplate>
  19.         <CustomNavigationTemplate> ..
  20.         </CustomNavigationTemplate>
  21.       </asp:TemplatedWizardStep>
  22.     </WizardSteps>
  23.     ..
  24.   </asp:Wizard>
  25. </ContentTemplate>
  26. </asp:UpdatePanel>
  27. ..
SERVER CONTROL:Works great in anyother place even in step 1
Expand|Select|Wrap|Line Numbers
  1. public class cSCDataGrid : WebControl, INamingContainer 
  2. {
  3.   protected DataGrid fGrid = new DataGrid();
  4.   ...
  5.   protected string generateJavaScriptCode()
  6.   {        
  7.     String scriptCode = ((flAllowHighlightOnMouseOver)?
  8.       "function HighlightRowOnMouseOver(row) { " +
  9.         "if (row.style.backgroundColor!='#336666') " +
  10.           "{ if (row.tabIndex==1) { " +
  11.               "row.style.backgroundColor='#F0FFC0'; } " +
  12.              "else { "+
  13.               "row.style.backgroundColor='#F0FFC0'; }}} ":
  14.        "");
  15.     return scriptCode;
  16.   }
  17.   protected override void CreateChildControls() 
  18.   {
  19.     ..
  20.     this.Controls.Add(new LiteralControl(
  21.       "<script language='javascript' " +   
  22.           "type='text/jscript'> " + ..
  23.         (flAllowHighlightOnMouseOver?
  24.            generateJavaScriptCode():"") +
  25.       "</script> ")); 
  26.     fGrid.ItemDataBound += 
  27.       new DataGridItemEventHandler(grid_ItemDataBound); 
  28.   }
  29.   private void grid_ItemDataBound(object sender,
  30.     DataGridItemEventArgs e)
  31.   {
  32.     if ((e.Item.ItemType==ListItemType.Item) ||
  33.         (e.Item.ItemType==ListItemType.AlternatingItem))
  34.       ..
  35.       if (flAllowHighlightOnMouseOver)
  36.         e.Item.Attributes.Add("OnMouseOver",
  37.           "javascript:HighlightRowOnMouseOver(this);");
  38.   }
  39.   ..
  40. }
Sep 30 '10 #3
Frinavale
9,735 Expert Mod 8TB
Ahha...There's your problem: you are out putting JavaScript into a Literal control and you are expecting it to work within an UpdatePanel.

When you are using UpdatePanels, any control within the UpdatePanel will cause asynchronous postbacks to the server.

In this case, if you do not register JavaScript methods that your controls use with the ScriptManager, then your JavaScript will stop working after any asynchronous requests occur. This is why your control works in the first step, but not in subsequent steps.

The ScriptManager control has a bunch of methods that allow you to register JavaScript with it. Go through them and find something that is appropriate for your situation (for example the ScriptManager.RegisterClientScriptBlock Method (Control, Type, String, String, Boolean) Method might be a good choice for you).

-Frinny
Sep 30 '10 #4
Thanks a lot Frinny, it was the right answer.. I have documented a bit more here: http://forums.asp.net/p/1608116/4109986.aspx.
Oct 4 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Ani | last post by:
I have a questionaire page , which basically has questions with multiple choice answers. I need to accomplish paging on this and there are few questions that are gender specific. According the...
3
by: Anders Both | last post by:
Does someone know´s about using threads and/or asynchronous programming inside asp.net (inside the asp.net process). I am here not speaking about the thing that the IIS makes new threads for each...
1
by: Abu Haider | last post by:
It took a while to find out the actual problem. I found built in server controls won't render properly in the latest version of Netscape and Mozilla etc. I thought they don't render css correctly....
4
by: V. Jenks | last post by:
What seems like a simple thing is apparently not so straightforward? I have a datalist. Inside of that datalist is an <itemtemplate> secion which contains other server controls such as a...
4
by: clintonG | last post by:
Technically speaking, this issue is not about modifying the HTML generated by server controls but preceding the HTML generated by server controls with an HTML control generated on the basis of the...
22
by: Mr Newbie | last post by:
I was thinking about developing a workflow application yesterday and was musing over the different approaches than one could take in restricting specific actions on a ticket( Form ) at any said...
2
by: John R. Lewis | last post by:
I posted this yesterday with a different email address. I am reposting with my fake-address as given to me by Microsoft so that I can be guraranteed a response from a support representative. Sorry...
6
by: Douglas J. Badin | last post by:
Earlier this month, there was a posting about this without a definitive answer. If you place a Wizard inside a FormView's EditItemTemplate the bound fields contained within the View will display...
0
by: tksc234 | last post by:
Hello there. My question is related to full custom server controls. 1) The 'input' element that caused the postback already has 'Me.UniqueID' in its name field. I assumed, the value of postDataKey...
0
by: anishps | last post by:
Hi all, I have an asp wizard with many steps and with a sidebar template . sidebar template is like this <SideBarTemplate > <aspataList ID="SideBarList" runat="server"> <ItemTemplate >...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.