简体   繁体   中英

ASP.NET Controls

Do you use ASP.NET control or just HTML with CSS?

I'm having some troubles with width in TextBox and DropDownList. In different browsers, the width will be different and the controls will not have the same size.

I'm considering change this to HTML tag like input and select, but I'm wondering why does ASP.NET has this controls if that they don't work? If they don't work, avoid them... right?

Give me information I need, make me better than before :-).

Here is the code:

<asp:DropDownList ID="ddlDirComercial" runat="server" CssClass="clsValor" Width="400px">
     <asp:ListItem Text="test" Value="1"></asp:ListItem>
</asp:DropDownList>

<asp:TextBox ID="txtCAE" runat="server" CssClass="clsValor" Width="400px" />

Regards.

I've used both ASP.NET controls and the HTML input fields as well. If you look at the source of the page, the TextBox results in an input created on the screen, so either way it wouldn't to use the ASP.NET control since it would be the same anyway. With the control you would have the ability to more easily access code on the server-side. If you have it available to you, I would just stick with the ASP.NET controls

Those controls can run "on" the server. That's at least one significant reason they exist. They aim to simplify the development of forms by providing a more Windows Forms like development environment.

For complex custom ajax driven content I tend to just do it all in javascript and the DOM.

And I agree. The controls work. But maybe not like you would expect.

Considering that the ASP.NET Controls render into regular HTML, I don't see how you have problems with the ASP.NET Controls width but not the regular width. Of course, I don't use Width and Height properties on ASP.NET controls because I use ASP.NET controls with CSS to set the width and other layout stuff.

Style differences between browsers are common in both server-side and client-side controls, and are far too easily fixed to destroy the advantages of working with ASP.NET controls (such as rapid development, easy data binding, fewer lines of code, etc.). If you find that a straight HTML control looks right, and a server control doesn't, try examining the generated HTML and comparing the two. The server controls are turned into client-side HTML, so there shouldn't be that much difference.

Cross-browser style differences are better solved through CSS than throwing away such a huge feature of ASP.NET. I also understand jQuery is very good for this sort of thing. If you can't get it looking right on your own, you might want to ask someone who specializes in Web design (assuming you have access to one).

Ok guys, I found the problem.

The problem isn't in ASP.NET but in input/select behavior with the doctype.

As I found here .

Thanks to all the answer, they're all good and click ans useful to all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM