Setting width for .net controls in code(.aspx) page using function call in code behind..


 Currently I am trying to set the width of the Table as follows.

<asp:Table width="<%=GetWidth()%>" >


and code behind

protected Unit GetWidth()


return Unit.Percentage(50);




It's not working. I know that it works if I set the width complete on some page event(like page_load) of code behind....


Is there a way to maintain the same syntax like calling code behind function in design page...i.e. calling function of .aspx.cs in .aspx page and assign the width as shown above.


Thanks and regards,


4/23/2009 6:29:19 AM 93655 articles. 6 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 55


for server controls try using <%# %> databinding tags instead of <%= %>.

<asp:Table runat="server" width='<%# GetWidth() %>' >

And in your codebehind remember to invoke DataBind() within the page load event handler.

Hope this helps. Bye!

Helping someone does not mean giving them what they need, but making them able to get it themselves
The Code Golem
4/23/2009 7:39:14 AM


Give Id of table and make it server control and then in code behind page load set width of table as:



Khushboo Nayak

Please Mark as Answered if this helps you

4/23/2009 8:43:09 AM

Similar Artilces:

How to use ODP.NET on aspx page (not in compiled code-behind)
Hi Folks. I'm trying to use the ODP.NET provider in an .aspx file in a <script> block. The page is not part of a "project", does not have a code-behind page, is not compiled, and I am not using VS.NET for development. <%@ Page Language="C#" %> <%@ Import namespace="System" %> <%@ Import namespace="System.Data" %> <%@ Import namespace="Oracle.DataAccess.Client" %> <script runat="server"> void Page_Load(Object sender, EventArgs e) { OracleConnection con = new Orac...

How to call a code behind function in user control from parent aspx page
Hi folks: Beginner needs help. I have a web user control and has a simple function "callme()" in it. This user control is added to an aspx page.How can I call  function "callme()" when a button is clicked in the aspx page?Any help  is greatly appreciated! Thanks!        Web hosting coupons Make the CallMe method public and in your ASPX button click event call <usercontroldid>.CallMe(). Hope that helpsThanksGaneshIf you find my reply help you Mark it Answered. just for html view of the aspx page. See th...

Setting Control Properties Using VB.Net Code in the aspx Source Files.
How would I set a property of a .net Control file in the source file to a Variable or a Function name in the code behind file.  I've seen various examples of this, but I have never understood the syntax. Is there a good tutorial on this? I would like to understand code like Text='<%# Bind("DepartmentDesc") %>' />. Hi, rspiet:I would like to understand code like Text='<%# Bind("DepartmentDesc") %>' />. Based on my experience, we could use Data Bind  Expressions like "<%%>" to bind the data sou...

how can i convert code behind web forms pages to inline code pages
hi all of you, I have a problem, a have registered a free space at Brinkster , so i can just upload my files there one by one, but can not install my web application directly, and i have to upload my projects there, so one way is o convert all my VS.NET web application which is code behind, convert that into inline code, so how can i do that Thanks in advanceWarm Regards,Prajesh Kumar JhaE-MAIL : Convert from Code-Behind to Code-Inline: Darrell Norton, MVPDarrell Norton's BlogPlease m...

function call inside aspx page for function in code behind not executing?
Hi,  I converted an .NET 1.1 web application to .NET 2.0 framework.The original .NET 1.1 page runs fine. The webpage has a datagrid, when a label control tries to be populated by a null value I get the following error:Conversion from type 'DBNull' to type 'Date' is not valid. the code on the aspx page: <asp:Label id="Label1" runat="server">        <%# AppDateFormat(DataBinder.Eval(Container, "DataItem.start_Date")) & " - " & AppDateFormat(DataBinder.Eval(Container,...

how to call controls of web control form in coding of other forms?
hello everyone i have one problem i have created one webcontrol shoppingcart in which there are two labels one of qty and other of amt which are initially enable =falsenow on other page(aspx page) i have one txtbox of qty as txtqty i want tat as soon as user enters qty txtqty and clicks on add cart button it shd be display d value in lblqty of web control shopping cart make sure i m using datalist on aspx page so give me suggestions on tat basis and my coding is in vb. plz give ur suggestions as fast as possible. Neeti what do you mean by webcontrol.... it this user control or normal ...

setting a controls properties within a master page from aspx page without code behind
I have a custom header control that has a public property TabID declared in the codebehind of the control itself. In asp1.1, I dragged the header control to a page and set the tabid like: <uc1:myheader runat="server" TabID="1" /> inside the aspx page it was placed. Now I would like to put the header control inside a master page, but I'm not sure how to set this property without setting it in codebehind for every page i create.  Is this possible? What is the best way to get this value to the header control as it is different for every page?...

Using code compiled code behind instead of aspx pages
Hi There, I have some code I wish to release to a customer (its a photo gallery with upload, autothumbnail and watermarking facilities). Currently this is in one stonking vb aspx file, and I was working under the (wrong) assumtpion I could just obfuscate the code ala html mangler (which I find I cant). So, I need to create a .vb code behind - which is ok - I dont mind the extra work, but having read some bits about this I have the following questions and would be grateful if anyone could point me in the right direction. 1) I dont particularly want the user screens html source vie...

Calling code-behind functions from aspx page
Hi, I’ve been struggling for the last few hours over something I think should be very basic: Q: How do I call a C# function in my codebehind file from my .aspx file? Please refer to the code highlighted in yellow below. Is this the correct way to call a codebehind function? I keep getting an error "Literal content ('</asp:MenuItem>') is not allowed within a 'System.Web.UI.WebControls.MenuItemCollection'" Here’s a snippet in my .aspx file: <asp:Menu ID="Menu1" runat="server">    <S...

I can not send to a textbox control a string using page-behind-code if the control textmode property is set to password???
I am working on a intra-webapp using, and for some reason I can not send a string value to a textbox control when its textmode property is set to password.  Is there a way to accomplish this? Thanks,...

Using App_Code shared code in page code-behind AND code-front
Hi all, I've only just come across what seems to be the 'correct' way of making use of shared code in my .Net sites: I code some classes in a .cs (in my case - i'm using c#) file. I then put them inside namespaces. To make use of the classes in the code-behind of my web pages, I simply add a "using MyNamespace;" line at the top, and then I can make use of a class' contents like so: "MyClass1.MyString1(SomeVariablesToSend)". Now that works fine when working in the codebehind, but what happens when I want to call the class/string from my code-fron...

Inline Coding (i.e. no Code-behind) and Wilson Pages (.Net 1.1)
Hi, I'm developing a personal web site and planning on hosting it on Brinkster, but Brinkster does not allow codebehind or using Dlls (from what I understand). But I would still like to use Wilson Master Pages, if possible.  I downloaded the free source code from the Wilson Master Pages website, but I'm not an advanced enough .Net programmer to firgure out how to use the source code using inline code.  Normally, you would use something like:<%@ Register TagPrefix="Wilson" Assembly="WilsonMasterPages" Namespace="Wilson.MasterPages" %>  on your templated pages...

use VB.NET and C#.NET code in the same C#.NET project
All-- Here is a sample that is "off the beaten path", (at least for me). Is it possible, in an ASP.NET application, using the code-behind page building technique, to have both pages written in VB.NET and pages written C#.NET?At there is a sample that shows that, (contrary to popular belief), it IS possible to mix ASP.NET pages built with C#.NET with ASP.NET pages built with VB.NET in the same VS.NET 2003 project. Note that this is just a "fun" sample to see if it can be done and I do not recommend this practice as a "standard" way of develo...

Setting focus on control in the code-behind VB.NET
Hello, Can anyone tell me if you see anything wrong with this code? I'm trying to set focus on txt_job textbox when a button is clicked. 1 Private Sub SetFocusScript(ByVal strTextBox As String) 2 3 Dim sb As New System.Text.StringBuilder() 4 5 sb.Append("<script language='javascript'>") 6 7 sb.Append("document.frmView." & strTextBox & ".focus();") 8 9 sb.Append("</script>") 10 11 ' register the script 12 13 ...

Web resources about - Setting width for .net controls in code(.aspx) page using function call in code behind.. -

Control - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Out-of-control car hits Ballajura pedestrians and puts four teens in hospital
Four teenagers were injured in Ballajura on Saturday night when an out-of-control car careered into them.

Is Hillary Clinton sorry she reacted to the San Bernardino massacre with a call for more gun control ...
... "Gun safety" has traditionally meant handling your guns safely, but now it's supposed to mean what has more commonly been called "gun control." ...

Trump pushes alternative to gun control after attack
Billionaire hits back against New York Times editorial calling for stronger gun control in wake of San Bernardino massacre

Porsche To Mission E Control: We Are Clear For Launch!
... handling of a Porsche. The contrast seemed to start early cries of the Mission E being the next Tesla [&hellip Porsche To Mission E Control: ...

EU could soon have border controls
EU ministers have agreed to press ahead with plans to suspend the Schengen passport-free travel zone, the FT reports.

CNN's Smerconish Brings On GOP Ratf*er Karl Rove To Opine Over Partisan Divide On Gun Control
... was time to pray. The New York Daily News ran a controversial cover noting that God wouldn't fix this. Democrats again made calls for gun control. ...

Attorney General Says Obama Could Call For Congressional Action For More Gun Control
Attorney General Says Obama Could Call For Congressional Action For More Gun Control

Open thread for night owls: First U.S. birth control clinic lasted just 10 days before being raided
... Parenthood Only Lasted for 10 Days but Started a Revolution . An excerpt: During her time in Europe, Sanger had seen Norwegian birth control ...

San Bernardino Shooting: National Rifle Association rubbishes Obama's gun-control appeal
San Bernardino Shooting: National Rifle Association rubbishes Obama's gun-control appeal - Hitting out at Barack Obama for politicising the incident, ...

Resources last updated: 12/7/2015 5:37:07 AM