Hello!
I developed a composite control that inherits from HyperLink and overrides
Render method.
In web form I am using this control with DataGrid. On DataGrid ItemDataBound
event I set ImageWidth and ImageHeight values programmaticall y. But on
post-back the control loses ImageWidth and ImageHeight values.
What I am doing wrong?
Thank you!
James
CODE:
-----------------------
Protected Overrides Sub Render(ByVal Output As System.Web.UI.H tmlTextWriter)
Output.AddAttri bute(HtmlTextWr iterAttribute.H ref, Me.NavigateUrl)
Output.RenderBe ginTag(HtmlText WriterTag.A)
If ImageUrl.Length = 0 Then
Output.Write([Text])
Else
Output.AddAttri bute(HtmlTextWr iterAttribute.S rc, ImageUrl)
Output.AddAttri bute(HtmlTextWr iterAttribute.A lt, [Text])
Output.AddAttri bute(HtmlTextWr iterAttribute.H eight, ImageHeight)
Output.AddAttri bute(HtmlTextWr iterAttribute.W idth, ImageWidth)
If Not (ImageHeight Is Nothing) Then
Output.AddAttri bute(HtmlTextWr iterAttribute.H eight, ImageHeight)
End If
If Not (ImageWidth Is Nothing) Then
Output.AddAttri bute(HtmlTextWr iterAttribute.W idth, ImageWidth)
End If
Output.RenderBe ginTag(HtmlText WriterTag.Img)
Output.RenderEn dTag()
End If
Output.RenderEn dTag()
End Sub 2 3501
you should save your values in a viewstate or a inline property... It loses
its state..
--
Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET
"James T." <gi*****@hotmai l.com> wrote in message
news:eX******** ********@TK2MSF TNGP14.phx.gbl. .. Hello!
I developed a composite control that inherits from HyperLink and overrides Render method.
In web form I am using this control with DataGrid. On DataGrid ItemDataBound event I set ImageWidth and ImageHeight values programmaticall y. But on post-back the control loses ImageWidth and ImageHeight values.
What I am doing wrong?
Thank you! James
CODE: -----------------------
Protected Overrides Sub Render(ByVal Output As System.Web.UI.H tmlTextWriter)
Output.AddAttri bute(HtmlTextWr iterAttribute.H ref, Me.NavigateUrl) Output.RenderBe ginTag(HtmlText WriterTag.A)
If ImageUrl.Length = 0 Then Output.Write([Text]) Else
Output.AddAttri bute(HtmlTextWr iterAttribute.S rc, ImageUrl) Output.AddAttri bute(HtmlTextWr iterAttribute.A lt, [Text]) Output.AddAttri bute(HtmlTextWr iterAttribute.H eight, ImageHeight) Output.AddAttri bute(HtmlTextWr iterAttribute.W idth, ImageWidth)
If Not (ImageHeight Is Nothing) Then Output.AddAttri bute(HtmlTextWr iterAttribute.H eight, ImageHeight) End If
If Not (ImageWidth Is Nothing) Then Output.AddAttri bute(HtmlTextWr iterAttribute.W idth, ImageWidth) End If
Output.RenderBe ginTag(HtmlText WriterTag.Img) Output.RenderEn dTag()
End If Output.RenderEn dTag()
End Sub
You should probably be storing those values in ViewState between postbacks.
Here's an example of a custom control that uses ViewState to store similar
custom values and retrieve them again when needed. http://SteveOrr.net/articles/InheritAndExtend.aspx
--
I hope this helps,
Steve C. Orr, MCSD, MVP http://SteveOrr.net
"James T." <gi*****@hotmai l.com> wrote in message
news:eX******** ********@TK2MSF TNGP14.phx.gbl. .. Hello!
I developed a composite control that inherits from HyperLink and overrides Render method.
In web form I am using this control with DataGrid. On DataGrid ItemDataBound event I set ImageWidth and ImageHeight values programmaticall y. But on post-back the control loses ImageWidth and ImageHeight values.
What I am doing wrong?
Thank you! James
CODE: -----------------------
Protected Overrides Sub Render(ByVal Output As System.Web.UI.H tmlTextWriter)
Output.AddAttri bute(HtmlTextWr iterAttribute.H ref, Me.NavigateUrl) Output.RenderBe ginTag(HtmlText WriterTag.A)
If ImageUrl.Length = 0 Then Output.Write([Text]) Else
Output.AddAttri bute(HtmlTextWr iterAttribute.S rc, ImageUrl) Output.AddAttri bute(HtmlTextWr iterAttribute.A lt, [Text]) Output.AddAttri bute(HtmlTextWr iterAttribute.H eight, ImageHeight) Output.AddAttri bute(HtmlTextWr iterAttribute.W idth, ImageWidth)
If Not (ImageHeight Is Nothing) Then Output.AddAttri bute(HtmlTextWr iterAttribute.H eight, ImageHeight) End If
If Not (ImageWidth Is Nothing) Then Output.AddAttri bute(HtmlTextWr iterAttribute.W idth, ImageWidth) End If
Output.RenderBe ginTag(HtmlText WriterTag.Img) Output.RenderEn dTag()
End If Output.RenderEn dTag()
End Sub This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Satya Bojanapally |
last post by:
Hi,
I am unable to add a pager for this composite control.
I had created a composite control in C#. The control is having 5 labels, one radio button and one DropDownList control. The composite control should display 2 columns and 2 rows per page. I am able to display 4 Composite Controls independently, when the user is changing the index of the DropDownList control, automatcially the output should get reflected on the composite control...
|
by: Paul Kia |
last post by:
I have an ATL composite control which I drop into a tab control dialog page
of an MFC application. When I click on the composite control and then click
anywhere outside the MFC application, the application immediately hangs!
Spy++ indicates that the application is hanging on the WM_GETDLGCODE message.
This problem does not happen if the ATL control is a standard (that is,
non-composite) control, neither does it happen if the composite...
|
by: sleigh |
last post by:
Hello,
I'm building a web application that will build a dynamic form based
upon questions in a database. This form will have several different
sections that consist of a panel containing one to many questions.
To keep it simple, I'll describe the basics of what I'm trying to
design.
I've created a TextBox composite control that consists of a label for
|
by: dx |
last post by:
I have the Microsoft Press: Developing Microsoft ASP.NET Server Controls and
Components book. It's starting to shine some light on control development
but there is something about composite controls that I don't understand...
I've included a snippet from Chapter 12 below on Composite Controls:
<start>
Override the CreateChildControls method to instantiate child controls,
initialize them, and add them to the control tree. Do not perform...
|
by: Jeff |
last post by:
Hi -
I am developing a composite control using VB.NET.
In the ASP.NET page using the control, How can I update a label text value
to reflect the value of a property of the custom control whenever the
composite control is changed? The label is not a part of the custom
control.
I've managed to correctly set the composite control properties whenever it
| |
by: Mark Olbert |
last post by:
This involves a family of related, databound ASPNET2 composite controls.
I've managed to arrange things so that the composite controls restore themselves from ViewState on postback after they're initially
configured during DataBind(). Thanks to Steven Cheng for pointing out that you have to set the constituent control properties after
you add them to the composite control collection for the restore to work!
However, I now have a...
|
by: multiformity |
last post by:
Ok, so I have gone off and documented the lifecycle of a page with a
custom composite control on it. You can find that document here:
http://www.ats-engineers.com/lifecycle.htm
Now, I am working on a much more complex grid example, and according to
my findings, the order should be like so:
Page Constructor
Page OnInit
|
by: Beavis |
last post by:
I hate to repost a message, but I am still at the same point where I
was when I originally posted, and hopefully someone else will see this
one...
Ok, so I have gone off and documented the lifecycle of a page with a
custom composite control on it. You can find that document here:
http://www.ats-engineers.com/lifecycle.htm
|
by: Eric |
last post by:
I have created a fairly basic composite control consisting of a Label
and a TextBox. In the overridden Render function, I'm creating a
table with two rows and each row contains a cell (td). The Label and
the TextBox are each rendered in one of the cells. Everything renders
fine. The problem is that depending on the column the control
represents I may want the textbox to be a different visible size
during both design and runtime. I...
|
by: shapper |
last post by:
Hello,
I am working in a class library with various custom controls.
In which cases should a control inherit Control, WebControl and
CompositeControl classes?
And when should a custom control implement INamingContainer?
In this moment I am working on a custom control that is composed by a
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |