|
The purpose of creating user controls is so that you don't have to have the same code written in a bunch of places. For example, one user control I use in all my projects is a calendar textbox. The control has a text box along with a calendar icon that calls a popup calendar. The reason it is in a user control is two fold. Throughout the entire application it functions the same and the code is one place.
|
|
|
|
|
You create user control just one time but use it for many times ... with a simple drag into your form ... !
you create it your self by your need and work , and use it whenever it is needed.
|
|
|
|
|
Great question!!.. I struggled with this question for quite sometime and could not understand why User Control were needed. Many senior developers answered my question by saying "It's the same as the #include file in classic ASP". Nonetheless, I never learnt or wrote classic ASP since during my Undergrad I was taught ASP.Net. Basically, the sole purpose of a user control is re-usability. The best explanantion would be that of the calendar as described in one of your previous response. A user control, for example is a login page, hence if a user needs to be logged-in to access a certain page on your site you can place the login (user) control on that page instead of re-writing that code on every page you need it on. In effect you write the code once and you can place it on as many pages as you like. It can be place in a table, placeholder or the page itself. This is done either programmatically using the @register directive or simply by dragging and dropping it on the page.
-- modified at 22:55 Wednesday 10th January, 2007
Skan
Coding makes the world go round!!!
|
|
|
|
|
If I can I would like to piggy back a question to yours. I would like to know, I am certain that it possible but unsure of how it is done, if the is a way a user control from a different project be imported into a current project which I am working. If so, would I use the namespace attribute of @register directive or do I need to use the @import directives. In the past the only way I have used a control from a different project was if I added it to the server toolbox. However I do not want to added to the toolbox content. All, I want to do is import the control and use it direct on the page. It this possible?
Skan
Coding makes the world go round!!!
|
|
|
|
|
For custom controls, just add a reference to the built dll of the control project.
For user controls (.ascx) you need to copy the files to your new project. If your not using 2.0, then the easiest way is to assign this control to the namespace of the page you want to use it on. 2.0 has no namespaces (you can use them, but there's no need to)
|
|
|
|
|
hi, can someone help me, I just check my website from firefox and the images are very big!! in internet explorer the images are good with my height and width size for the images. But with firefox, images are showing in their default size. how can i solve this problem
The website is: www.ivanandsimone.com/query/home.aspx
Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.
|
|
|
|
|
For firefox, you'll need to set the height and probably width attributes for the IMG element. Setting the height for a table and not for the image isn't likely to be honored by many browsers when the image is larger than the table cell.
|
|
|
|
|
thanks, but how to set the attributes please?? Thanks alot..
Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.
|
|
|
|
|
|
I have it like this:
asp:imagebutton id="imgItem1" runat="server" Height="75px" Width="93px" ImageAlign="Middle" asp:imagebutton
But its not working
Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.
|
|
|
|
|
Not sure why you're using ImageButton when Image should work fine on it's own. However, look at the code for your page: http://www.ivanandsimone.com/query/Item.aspx[^]. It seems to be sizing the image as it should. Compare what's different in your code and that should solve your problem.
|
|
|
|
|
hi, i am using imagebutton because i want the user to click on it and it leads him to another website with the picture's contents as you can see from www.ivanandsimone.com/Query/Home.aspx..
Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.
|
|
|
|
|
When a page looks different in Firefox and Internet Explorer, it's almost always Firefox that renders the page correctly.
The input fields that you use to display the images are inline objects, so setting width and height does not apply to them. Internet Explorer incorrectly applies the size to the fields anyway. Opera and Netscape handles it correctly, though, just as Firefox. You have to turn the fields into block objects using display:block if you want to be able to set the size.
Do yourself a favour and test the page in Firefox while you are building it. Then there is a very good chance that it will also look the same in all the other browsers, except Internet Explorer or course. You will often need to do some tweaking to make it work in Internet Explorer also, but it's much easier than to tweak a page that only works in Internet Explorer into working in all the other browsers also.
---
Year happy = new Year(2007);
|
|
|
|
|
Hey experts,
I have a aspx page with a datasource that select images from a mysql database. This datasource i binded with two FormViews.
1st: Displays all images as thumbnails in a left column.
2st: Displays the full image that is selected in left column.
Now for my question. I have noticed that the selected and selecting events is fired twice. Guess this is the way the sqldatasource control works...
By is there any way to stop the events firing twice. Seems like big overhead selecting images as blob from a database twice, when one time would be enough.
Hope somebody out there know someting about this.
Regards Anders, DK
|
|
|
|
|
You can set the EnableCaching property to true and use a couple of caching properties of the control to cache data from the Select method. See SqlDataSource Members [^]
|
|
|
|
|
Ahhh simple solution, like it. Thanks alot, works like a charm.
-Anders
|
|
|
|
|
Hi all. I am developing application in C#. I have a web page with some data to be PRINTED. I want to know How I can Print the page in ASP.NET 2.0. Please guide me in this regard. If somebody know any tutorial about it, please tell me its url. I will be very thankful to you.
|
|
|
|
|
Your app needs to print on the browser end, so either the user has to select print, or if there's a function in javascript that forces a print ( I think there is ), you need to call that on the client side in response to a click.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi, i use C#-Aspx with VS2005. I try to display an image in a DataGrid-Column, which comes as a Byte Array from a DataBase.
I have this code:
...
<asp:BoundColumn DataField="Title"
HeaderText="Title">
</asp:BoundColumn>
<asp:ObjectDataSource ID="MyDataSource" runat="server"
SelectMethod="GetData"
TypeName="MyApp.Helper">
<SelectParameters>
<asp:ControlParameter ControlID="MyDropDownList"
Name="MyId" PropertyName="SelectedValue" Type="Object" />
</SelectParameters>
</asp:ObjectDataSource>
...
How can i add a picture-column after the boundcolumn ?? I don`t want to use
an extra "loadpicture.aspx", etc..
I tried to add: "<%Response.BinaryWrite(Picture)%>", but i got the error, that "Picture" isn`t known.
I tried TemplateColumn, too, but i need a ImageUrl for this (which need a loadpicture.aspx ;().
Is this new "DynamicImage" the solution ??
Thx
Lurker32
|
|
|
|
|
Lurker32 wrote: "<%Response.BinaryWrite(Picture)%>",
Do you have a variable or property called Picture in your class ?
Lurker32 wrote: I tried TemplateColumn, too, but i need a ImageUrl for this (which need a loadpicture.aspx ;().
Why do you need a seperate page to load your picture ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I made it with a Gridview (and an imagefield) instead of DataGrid.
...
dataimageurlfield="ID"
dataimageurlformatstring="loadImage.aspx?MyId={0}"
...
The loadImage (with code-behind) takes the ID and calls a method, which gives several strings
and the picture-bytearray in return.
-- modified at 7:09 Friday 12th January, 2007
|
|
|
|
|
i develop some reports using crystal report and when i run the report in ie browser,it get all of data in one page but when i print the report it print in alot of page and the page header visiable in first page.
i want to visiable the page header in all page
thanks
|
|
|
|
|
I haven't used crystal in a long time but if I remember correctly the only thing you can do is render a pdf to client and the user print that. The html version never prints just right.
|
|
|
|
|
Hi,
I have an value bound to a column in a datagrid. I need to pass that value to a function. I thought this would easy for me.
I used something like:
Dim e As DataGridItem<br />
ds = obj.getDetails(e.Cells(0).Text)
This would mean that it is trying to extract as a string OR convert the contents of the cell to string. I need the value to be extracted as an integer. Char to Integer conversions cannot happen.
Please advise me if you can. Is there a straighforward way to extract the value of that cell?? Thank you.
-- modified at 9:52 Wednesday 10th January, 2007
|
|
|
|
|
The table cell contains a string value, not a number. If you want the value as a number, you have to parse the string.
If the value in the table cell comes from a numeric field in the data source, you have to read the value from the data source instead of from the table cell to get it in the original numeric form. When the value is put in the table cell it's convertered into a string value.
---
Year happy = new Year(2007);
|
|
|
|