I can resize a textbox at runtime and do other modifications. However I want to move it left or right. I tried
textbox1.location = new point (150,200)

however the error, location not one of textbox asp... properties appears.

Please let me know if there is any help for me.

thanks

Dani AI

Generated

The TextBox on an ASP.NET page renders as a normal HTML input, so the WinForms-style Location property is not available on the server control. attempted a WinForms approach; layout on the Web is handled by HTML/CSS in the browser rather than a server-side Location property. was on the right track pointing at client-side work.

A practical approach is to give the element a positioning context (for example position: absolute inside a relatively positioned container) and change its left/top values from script. When referencing an ASP.NET control from client script, use its rendered id (for example TextBox1.ClientID) or set ClientIDMode="Static" so the id is predictable.

Example client-side code:

var tb = document.getElementById('<%= TextBox1.ClientID %>');
tb.style.position = 'absolute';
tb.style.left = '150px';
tb.style.top = '200px';

Notes and gotchas: absolute positioning removes the element from normal flow, so surrounding layout can shift; prefer placing the input inside a relatively positioned wrapper to confine movement. For smooth animations, use CSS transforms (GPU-accelerated) instead of repeatedly changing left/top. If the move must be done on the server (postback), emit the appropriate inline style or CSS class from server code. See the browser guidance on CSS positioning (CSS position) and how to obtain the control id from ASP.NET (Control.ClientID).

Recommended Answers

All 2 Replies

If you want to do some cool stuff and does not want to mess the performance of the system, try to use javascript.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.