Link to home
Start Free TrialLog in
Avatar of leebee300
leebee300

asked on

Component placement

I am trying to place a textbox next to a radiobuttonlist, asp.net puts a line break between them by default. Can this be stopped so the they are both on the same line on the webpage ???
Avatar of alorentz
alorentz
Flag of United States of America image

Maybe you'll post the HTML for the whole page in this post?  The 2 object stay on the same line unless you force them to break lines.  So there is somehting else in your HTML that is causing the problem.  I tried to tell you that in the previous question.
Avatar of leebee300
leebee300

ASKER

I know Alorentz but I do not like posting the code, for certain reasons (not bad reasons obviously), I noticed on another website forum type thing someone else had the same problem but there where no solutions on that one either
Well, the problem is somewhere in your HTML structure! If you put the code I gave last time in a new file with no tables, you'd see that they are on the same line, BY DEFAULT.  If you can't provide the information we need to help, how are we supposed to help?
I know I know dont give me a hard time please, I will try your previous code in a new table, then if correct (which you usually are) I will have to re do the tables.
Here it is again:

<asp:textbox id="TextBox1" runat="server"></asp:textbox>&nbsp;&nbsp;
<asp:radiobuttonlist id="testbutton" runat="server" RepeatDirection="Horizontal">
      <asp:ListItem Value="yes1">Yes</asp:ListItem>
      <asp:ListItem Value="no1">No</asp:ListItem>
</asp:radiobuttonlist>
Alorentz, I tried this code, and it does default automatically on to a new line, try it, save it then access the file through a browser

<html>
<head>
</head>
<body>
    <form runat="server">
        <asp:TextBox id="test" runat="server" size="10"></asp:TextBox>
        <asp:RadioButtonList id="testbutton" runat="server" RepeatDirection="Horizontal">
            <asp:ListItem id="testYes" value="Ty" text="Yes" runat="server" />
            <asp:ListItem id="testNo" value="Tn" text="No" runat="server" />
        </asp:RadioButtonList>
    </form>
</body>
</html>
What the hell?  Now if doesn't work for me either!  Strange.....
very strange isn`t it
Yes, I saw that...looks like your going to have to put in table cell:

<html>
<head>
</head>
<body>
    <form runat="server">
       <table>
           <tr>
               <td>
        <asp:TextBox id="test" runat="server" size="10"></asp:TextBox>
               </td>
                <td>
        <asp:RadioButtonList id="testbutton" runat="server" RepeatDirection="Horizontal">
            <asp:ListItem id="testYes" value="Ty" text="Yes" runat="server" />
            <asp:ListItem id="testNo" value="Tn" text="No" runat="server" />
        </asp:RadioButtonList>
               </td>
           </tr>
</table>
    </form>
</body>
</html>
The problem is the the server side compiler builds the HTML table for it and puts it on a new line if one is not present in the code.  So you need to build in the structure.

OR, use absolute positioning for all the elements on the page.
NNNOOOOOOOOO no no no no no, what a downer !!!!!!!! I have spent ages designing the table and I am practically at the end of the webpage, I have components everywhere !!!!!!!! is there definately no easy fix that you or any of your friends maybe aware of ????
This is a function the .Net compiler, can't control that.  I assume you have these objects in the same table cell, an if nowrap didn't work, your sh@t out of luck!

Sorry.
You'll see for the original code I gave you, that if you view source of the page, you'll see the built in HTML that you have no control over.
yep its in the same table cell, funnily enough it defaults when I use the buttons in other cells, sh@t out of luck it looks like then, thanks for the help on this one anyway Alorentz (I will still search though, it seems that it could be too common a problem to have not been addressed by Microsoft(spot my niavety there !!!!))
you can also try the .Net area instead of here in ASP.  They do all .Net there:

https://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/

thanks Alorentz, points are dissappearing fast with no readies to replace them, so I will have to be extra careful now
Just a thought, but what if instead of using the <asp:RadioButton >, you just used the <INPUT type="radio" runat="server"> ?? I know it's the generic HTML object and it's not as robust on the codebehind, but it might resolve your formatting issue. I've not tried it myself, it's just a thought.
yes it does work but it is defeating the object, and knowing Microsoft it will cause a problem somewhere along the line, but thanks for the idea anyway.
How's it "defeating the object"? You sounded so despondant that you'll have to recode everything, why are you giving up on this so fast if it works? Just curious. Also, if ASP.NET stops supporting generic HTML objects, then more people than you will have a problem. ;)
a fair point, it worst comes to the worst I will try it.
It will work, but if will defeat the purpose of web form controls and ASP.Net
thanks Alorentz, couldn`t have put it better myself
Could you explain to me why alorentz?

If all I want is to know the selected value, and I'm not trying to process events on the radio button, what's the harm? It's just a way of retreiving information from the user. What is the difference between an <asp:RadioButton runat="server"> and an <input type="radio" runat="server"> aside from the more generic interface of the latter in the codebehind?
if your going to discuss it on my post could you also please try to find a solution for me please aswell guys.
ASP.Net is application based and there is more to it than just knowing a value.  There are several additions functional capabilities of server controls, and additional coding necessary to incorporate old ASP objects into ASP.Net.  I guess you'd need to write an ASP.Net app to see what I'm talking about, it's a whole new world...
>if your going to discuss it on my post could you also please try to find a solution for me please aswell guys.

Told you how to do it....just doesn't suit your code now.  Post to .Net area...you're not going to get much help for this here because this is basically classic ASP area.
get a sense of humour Alorentz I was joking with that post
Ok, change the repeatLayout to "Flow" that should do it.
you gotta put the smiley face on the end for a joke, it's really hard to tell the tone of text. ;)
nope unfortunately I put that command in the <body> section but it had no affect at all.
ok :)
try in the radio control. Use the Dev Environment.
I just tried the original code and it didn't work. Then I changed the radio control's property as I suggest  and it works.
>Ok, change the repeatLayout to "Flow" that should do it.

The HTML for the server control is auto generated, so flow can't effect it, because compiler puts it in tables.
Here's the HTML that the design view generates:

<asp:TextBox id="test" runat="server" size="10"></asp:TextBox>
<asp:RadioButtonList id="testbutton" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
      <asp:ListItem Value="Ty">Yes</asp:ListItem>
      <asp:ListItem Value="Tn">No</asp:ListItem>
</asp:RadioButtonList>
I stand corrected!!!  I will bury my head in the sand!
Yah, the HTML is generated by the server. But if you tell the server to generate the HTML using "Flow" instead of "Table" the compiler won't use tables, no? All I know is I could replicate the problem and resolve it on my system, it's just a matter of getting it to work for leebee300.
ASKER CERTIFIED SOLUTION
Avatar of sforcier
sforcier

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Now you know why I'm in ASP Area, not .Net... ;-)
thanks for the help you two, you have helped me a lot :)