Click here to Skip to main content
15,887,369 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to programatically change the position of 'table76' in code behind. It throws an error stating 'The name table76 does not exist in the current context'. Is it because it is inside update progress? My code:

XML
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
   <ContentTemplate>
   <asp:Label ID="Label99" runat="server" Width="145px"></asp:Label>
   </ContentTemplate>
   <Triggers>
   <asp:AsyncPostBackTrigger ControlID="Button4" EventName="Click"/>
   </Triggers>
   </asp:UpdatePanel>

<asp:UpdateProgress ID="UpdateProgress1"  AssociatedUpdatePanelID="UpdatePanel1" runat="server">
<ProgressTemplate>
<table cellspacing="1" class="style56w" runat="server" table id="table76">
<tr>
<td>
<asp:Image ID="Image21" runat="server" DescriptionUrl="~/images/updateprogress.gif"
Height="60px" ImageUrl="~/images/updateprogress.gif" Width="20px" BackColor="White"/>
</td>
</tr>
</table>
</ProgressTemplate>
</asp:UpdateProgress>



code bhind:

table76.Style.Add(HtmlTextWriterStyle.Top, "1140px");
Posted
Comments
Sergey Alexandrovich Kryukov 26-Aug-13 23:52pm    
What "code behind"? You cannot show just one line and ask for help. Apparently, table76 is not declared in your context.
—SA
S.Rajendran from Coimbatore 27-Aug-13 0:16am    
'table id=table76' is declared already in the script

Please see my comment to the question. Probably you meant to use ID. Please see: http://msdn.microsoft.com/en-us/library/y81z8326%28v=vs.100%29.aspx[^].

See also: http://msdn.microsoft.com/en-us/library/1d04y8ss%28v=vs.100%29.aspx[^].

—SA
 
Share this answer
 
v2
Please try following code where I have modified table in update progress bar

ASP.NET
<asp:updatepanel id="UpdatePanel1" runat="server" xmlns:asp="#unknown">
   <contenttemplate>
   <asp:label id="Label99" runat="server" width="145px"></asp:label>
   </contenttemplate>
   <triggers>
   <asp:asyncpostbacktrigger controlid="Button4" eventname="Click" />
   </triggers>
   </asp:updatepanel>
 
<asp:updateprogress id="UpdateProgress1" associatedupdatepanelid="UpdatePanel1" runat="server" xmlns:asp="#unknown">
<progresstemplate>
<table cellspacing="1" class="style56w"  runat="server" id="table76">
<tr>
<td>
<asp:image id="Image21" runat="server" descriptionurl="~/images/updateprogress.gif" 
Height="60px" ImageUrl="~/images/updateprogress.gif" Width="20px" BackColor="White"/>
</asp:image></td>
</tr>
</table>
</progresstemplate>
</asp:updateprogress>


write using in code behind file
C#
using System.Web.UI.HtmlControls;


after that you can access your table in code behind file

C#
HtmlTable table = UpdateProgress1.Controls[0].FindControl("table76") as HtmlTable;
table.Style.Add(HtmlTextWriterStyle.Top, "1140px");
 
Share this answer
 
v2
Comments
S.Rajendran from Coimbatore 27-Aug-13 0:43am    
Now the error has gone but when I change the Top as 800px or so it has no effect
S.Rajendran from Coimbatore 27-Aug-13 0:56am    
In continuance with the above I would like to state that the image is at 1140px even when I change to Top,800px. The 1140px setting is at the style sheet.
Sandeep Singh Shekhawat 27-Aug-13 1:20am    
Please try following code on code behind page

HtmlTable table = UpdateProgress1.Controls[0].FindControl("table76") as HtmlTable;
table.Style.Add("padding-top", "800px");
S.Rajendran from Coimbatore 27-Aug-13 2:12am    
Sorry,it is not changed.
Sandeep Singh Shekhawat 27-Aug-13 2:24am    
If my solution has resolved your issue please mark as accepted answer or upvote so that next time anybody get fast solution. Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900