Hi, I have a rather stupid question, hope someone can help me. I am writing a webpage in C#, in VS.NET 2003. To make things easier I used some user controls. However, my question how can I access the controls in the webpage. Let's say I have my aspx page A, and user control B that is within the aspx page A. I have a textbox in the User control B. And I want to pass the value of the textbox to another page from a Button in Aspx page A. The regular approach of Session["textboxvar"]=TextboxB.Text simply doesn't work. VS.NET 2003 is complaining "The type or namespace name 'TextboxB' could not be found." How can I access it? Many, many thanks!!!
Infernojericho
Posts
-
HELP! Accessing controls on a user control -
Simple question on Datagrid and Datalist.Hi fellas, this should be a pretty simple question. Is it possible to restrict a datagrid or datalist in the number of records displayed? For example, I only want to show 1 record in a datagrid. (Since I have a bunch of records each time it ends up displaying everything retreived) I tried using Paging feature and manage to display only 1 record at a time, however the "page changer buttons ( < > )" is displayed, can it be disabled? Worse, Datalist doesn't seem to support paging, how exactly do I set the number of data to be displayed? Many, many thanks for the help.
-
Stuck with Datagrid and its HTML output formatting......Thank you thank you thank you thank you!!!! I just can't believe it is that simple, I never quite figured out the difference between Datagrid and Datalist. Now I guess I do. I hope you wouldn't mind me asking another question. It's on textbox and labels. How do you create a "multiline" label? I tried using a textbox, and disabling the borders to make it look like a label, and to set it read only. However I've ran into several issues: The scrollbar is a problem, as it gives others the impression its a textbox after all, I managed to hide the scrollbar with the help of CSS. But this brings another problem: The number of rows in a textbox is fixed. So there is a problem with text longer than the textbox themselves, since I have disabled the scrollbar so users can't scroll, meaning they are unable to read the latter part of the text. I eventually thought of setting the number of rows in the textbox dynamically by getting the length of the string, divide it by the number of characters in each row on the textbox. So if the string to be displayed is like 100 characters long, and my textbox displays 10 characters per line. I do something like: textbox.Rows = string.length / 10. It's not perfect, though. BIG PROBLEM: There is a problem if there are carriage returns (Enters) in the text itself? Let's say if the user types "enter" twice at the 11th character, Basically there should be spaces from character 12 to 30. However when determining the string length does not see the 2 carriage returns as 18 spaces. Therefore it still sets the textbox as 10 rows, although the text takes up 12 rows. I am absolutely stuck in how I should solve this. Can anyone help?
-
Stuck with Datagrid and its HTML output formatting......Hi there, I have a question which has got me stuck for the past couple of days. My question is related to datagrids and HTML. I am well aware how datagrid works and data is retreived. I create the database connection, then pass the data to a dataset, on the HTML side I use the Databinder to display the data. I use the template column for higher customization. Here's an example: <asp:datagrid id.....=""> <columns> asp:templatecolumn <itemtemplate> <table> <tr><td><%# DataBinder.Eval(Container.DataItem,"DATATOBESHOWN") %></td></tr> </table> </itemtemplate> </asp:templatecolumn> </columns></asp:datagrid> The data will be shown in the following format: DATA1 DATA2 DATA3 DATA4 DATA5 DATA6 However, what I want to do is something like this: DATA1 DATA2 DATA3 DATA4 DATA5 DATA6 My point is, I need the next DATATOBESHOWN to be displayed on the right of the just-retreived DATATOBESHOWN, not on the next line. Can it be done? It seems it is the basic HTML properties that wouldn't allow me to do it. Anyone has any ideas? I tried placing the TABLE tags outside the Datagrid tags. No luck. Any clues in what I should do?
-
Urgent question on displaying Binary IMAGE data to a Datagrid in C# ASP.NETAlright, many thanks again for the assist.
-
Urgent question on displaying Binary IMAGE data to a Datagrid in C# ASP.NET -
Urgent question on displaying Binary IMAGE data to a Datagrid in C# ASP.NETThanks, Christian. Greatly appreciated. I'll take a look at it right now.
-
Urgent question on displaying Binary IMAGE data to a Datagrid in C# ASP.NETHi Christian, thanks for your reply (again). I am afraid I am not very good in ASP.NET (I think you can tell that already), and I am quite lost. Do you happen to know any sites on the web with similar examples? Many thanks again.
-
Urgent question on displaying Binary IMAGE data to a Datagrid in C# ASP.NETHi, I have a VERY URGENT question on C# in ASP.NET. I am building an ASP.NET WEB application. Does anyone know how to retreive BINARY image from a SQL Server 2005 Express Database and DISPLAY it on a Datagrid control? I can manage to retreive the Binary Data, but I have absolutely no idea how it can be placed into the dataset, or accessed via the Databinder. I can only display regular string data onto a Datagrid Control. This is my method in displaying string data onto a Datagrid: 1. From the Codebehind, I connect to the database. 2. I then use a DATASET and store the retreived data 3. In the HTML page, I use the Databinder to load the data (<%# DataBinder.Eval(Container.DataItem,"NAMEOFDATABASECOLUMN") %> However this method only works for strings, I need to display Binary Image, can anyone help me? Thank you!!!
-
Is it possible to place a hyperlink within a ASP.NET textbox control?Thanks for the reply. Do you know if there are any 3rd party, and free (hopefully) textbox controls that support Hyperlinks? Thanks!
-
Is it possible to place a hyperlink within a ASP.NET textbox control?Just a quick question, is the ASP.NET textbox control only capable of displaying pure text? Is there anyway to embed a HTML link inside the textbox? Thanks! If not, is there anything else I can use? Thanks!!!
-
How to place a condition in a template column in the datagrid?Thanks for the reply. Here is the code for the part that displays the Template Column.
<asp:TemplateColumn HeaderText="Subject" ItemStyle-CssClass="content"> <HeaderStyle CssClass="subtitle"></HeaderStyle> <ItemStyle Width="350px"></ItemStyle> <ItemTemplate> <asp:HyperLink id="Viewmessage" runat=server CssClass="content" NavigateUrl='<%#"viewmessage.aspx?messageid=" + DataBinder.Eval(Container.DataItem,"messageid") %>'> <font class="content"> <%# DataBinder.Eval(Container.DataItem,"messagesubject") %> </font> </asp:HyperLink> </ItemTemplate> </asp:TemplateColumn>
As you can see, the code above only retreives the SUBJECT and displays it. Is it possible to put a IF condition in the HTML Code? It is possible to do something like this?<asp:TemplateColumn HeaderText="Subject" ItemStyle-CssClass="content"> <HeaderStyle CssClass="subtitle"></HeaderStyle> <ItemStyle Width="350px"></ItemStyle> <ItemTemplate> <asp:HyperLink id="Viewmessage" runat=server CssClass="content" NavigateUrl='<%#"viewmessage.aspx?messageid=" + DataBinder.Eval(Container.DataItem,"messageid") %>'> <%# if (DataBinder.Eval(Container.DataItem,"opened") == "no") { SET FONT = BOLD } %> <font class="content"> <%# DataBinder.Eval(Container.DataItem,"messagesubject") %> </font> </asp:HyperLink> </ItemTemplate> </asp:TemplateColumn>
Thanks!!! -
How to place a condition in a template column in the datagrid?Hi, I am stuck big time with a problem in Data Grid. I am using C#, in VS.NET 2003. I am writing a simple web mail system, and I am using the datagrid to display the inbox. It is a very standard inbox, nothing fancy, and I am displaying the sender, subject, as well as the date sent. For each message there is an extra column "opened" which denotes whether the message has been read. Here's what I am stuck, I need to BOLD the message subject for those messages which are unread. I have absolutely no idea where to place the codes, the pseudocode is very simple, simply: If the "opened" column for that particular message is NO, then BOLD the subject Where do I place the codes? I tried to place it in the HTML code as well as the codebehind, no luck. Any suggestions??? HELP!!! Thanks!!!
-
Help with reading binary data (photos) using Oledb [modified]Hi there. I am currently working on a website assignment and I need some desperate help. I am using SQL Server 2005 Express Edition to store my data. I am using C# to write my site. I have used the OleDb to connect to the database, and to write and read the values. I have stored binary data (photo, jpeg) via Oledb, there is no problems at all. However I am stuck big time with retreiving photos. I am also using OleDb to connect to the database, then I placed the retreived data into a Dataset. I was able to retreive other information (such as name, phone numbers) from the dataset. However I am unable to retreive the binary data from the dataset. I've searched the web, it seemed everyone is using SQLDataReader, so I was curious it is possible to retreive binary data using OleDb at all? HELP! Any feedback would be appreciated, thanks!
modified on Monday, March 3, 2008 12:15 AM
-
Desperate! CSS + Session + SQL Server with C# ASP.NETThanks for the reply. Here's the problem. The database connection codes are at the page load section. What the DB codes does is it connects to the db, retreives the CSS values, then stores the CSS values in a session variable. However if the CSS style sheet goes before the db connection then the CSS style sheet won't receive any values???!!! Thanks
-
Desperate! CSS + Session + SQL Server with C# ASP.NETThanks for the reply. This is the entire content of the CSS style sheet. The code worked when it was an internal style sheet (inside the . I simply copied and pasted it to a new file, styles.css. Or am I missing something here?
<style type="text/css"> <!-- /* CSS Tabs */ #navlist { padding: 3px 0; margin-left: 0; border-bottom: 1px solid <%=Session["common_borderlinecolor"]%>; /* LINE BORDER, THICKNESS OF LINE */ font: <%=Session["tab_fontstyle"] + " " + Session["tab_fontsize"] + "px " + Session["common_fontname"]%>, sans-serif; } #navlist li { list-style: none; margin: 0; display: inline; } #navlist li a { padding: 3px 0.5em; margin-left: 3px; border: 1px solid <%=Session["tab_borderlinecolor"]%>; /* LINE BORDER */ border-bottom: none; background: <%=Session["tab_mouseawaybgcolor"]%>; /* TAB BACKGROUND OF REGULAR TABS */ text-decoration: none; } #navlist li a:link { color: <%=Session["tab_unvisitedfontcolor"]%>; } /* FONT COLOR */ #navlist li a:visited { color: <%=Session["tab_visitedfontcolor"]%>; } #navlist li a:hover { color: <%=Session["tab_mouseoverfontcolor"]%>; /* COLOR OF FONT IN TAB WHEN MOUSE OVER */ background: <%=Session["tab_mouseoverbgcolor"]%>; /* COLOR OF TAB BACKGROUND WHEN MOUSE OVER */ border-color: <%=Session["tab_mouseoverbordercolor"]%>; /* COLOR OF TAB BORDER WHEN MOUSE OVER */ } #navlist li a#current { background: <%=Session["tab_currentbgcolor"]%>; border-bottom: 1px solid white; } --> </style>
-
Desperate! CSS + Session + SQL Server with C# ASP.NETThanks for the reply. I am certain the DB is fine. I am stuck with the following: My index.aspx is basically filled with user controls. Some of the CSS settings also applies to the user controls. Therefore I have external Style sheet links within the user control files too. My question is when the index.aspx is loaded, does it first load the user control files that are linked with the index.aspx, then it loads the Page_Load of the index.aspx, where the database codes are stored. This is the only reasonable explanation I can come up with, since when the User Controls are loaded the DB connection codes aren't executed yet. Any ideas? Double thanks! This is driving me nuts....
-
Desperate! CSS + Session + SQL Server with C# ASP.NETThanks for the replies. I am quite certain the Database itself is fine. I experimented by placing the database connection codes right under the Page_Load section of index.aspx. Then I created a dummy label on the index.aspx, and have it print out one of the values retreived from the database onto the label. Worked fine. Is there anywhere else I can store the database connection codes? I thought placing it under the Page_Load is pretty much the best bet. I just can't think of anywhere else. I do need to know does VS loads the user controls first, then it loads the Page_Load of the index.aspx.
-
Desperate! CSS + Session + SQL Server with C# ASP.NETI guess I forgot to mention the reason I am storing it in the database it because I want the user to be able to set different color schemes for the site.
-
Desperate! CSS + Session + SQL Server with C# ASP.NETHi fellas, I'm stuck big time with my site. I'll try to make it short and simple. I am currently trying to write a website in the C# of ASP.NET. I am writing it in VS.NET 2003. I needed to use CSS for flexibility, so I decided to store the values of the CSS in a SQL Server Express 2005 Database. I also use a lot of user controls, I used a user control for my tabs on the site, another for the list buttons. However since there are quite a few pages in the site, I decided to use the external style sheets, since updating them would make my life easier. After the CSS values is retrieved, the values are stored in a session variable, then the style sheet links with the CSS session variables. I have placed the database connection in the very first line of the Page_load of the index.aspx. The problem is, it seems the CSS values are never loaded. Here's what I've tried and done: 1. Using internal style sheet (by placing it in the HEAD header) seems fine, the CSS worked. 2. I am certain the database connection is fine; I made a dummy label on the index.aspx, and I was managed to print the value from the database onto the Label. Therefore I am suspecting the culprit is the user Controls are loaded first, then the database. Therefore the CSS could never retreive the CSS values from the database. Could there be anything else? I am stuck big time. HELP!!!