Solved

Swapping of controls on a web form (mirror image) (ASP.NET)

Posted on 2004-10-20
9
189 Views
Last Modified: 2010-04-06
HI All!!
 I am developing an application in ASP.NET (code behind VB.NET) and one of the main functionality of the page is that on clicking of a button on the page, a mirror image of the page is shone (all the controls on the page are swapped eg. All controls from right to left will now be left to right).
 Could you pls give me the codes for doing this? it would be great if I could get codes in VB.NET
0
Comment
Question by:mim_jr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 125 total points
ID: 12374812
When you generate the page give the body an id:

<body id="bod">

Then the control looks like this:

<input type="button" value="mirror image"
onclick="document.getElementById('bod').style.direction='rtl'">


Cd&
0
 
LVL 5

Expert Comment

by:crimson117
ID: 12386663
Do you mean make the text you enter have its direction reversed, or do you mean:

[button1] [button2] [input3]

when you click the switch button/link, it becomes:

[input3] [button2] [button1]

?

You could probably use a div around each form element, then position each div with CSS.  

   <div class='css_class1' id='div1'><input type='text'></div>

When you want to reposition the fields, use javascript:

   div1.class='reversed_css_class1';


Note: this wouldn't be very scalable - you'd have to change the code if you changed the number of elements on the page.

A better implementation would be to parse the DOM of the page, then rewrite it with the form elements in backwards order, but I'm not a DOM expert so css is how I'd do it :-)

And actually, if you're of the "css=layout" "html=data" school of thought, then my first solution is actually better than messing with the DOM with javascript.
0
 
LVL 2

Expert Comment

by:udayms
ID: 12387053
I think COBOLdinosaur's answer would solve your issue
0
WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

 

Author Comment

by:mim_jr
ID: 12387321
Thank !! well yes i want it 2 b like ..
[button1] [button2] [input3]

when you click the switch button/link, it becomes:

[input3] [button2] [button1]

Can you pls let me know the contents of the 'reversed_css_class1'...
....
I will also try the solution given by  COBOLdinosaur's today... thanks to all
0
 
LVL 5

Expert Comment

by:crimson117
ID: 12388718
As I said, this isn't very scalable, but it works:


<html>
<head>

<style type="text/css">
.boxleft
{
position: absolute;
top: 100px;
left: 50px;
background-color: blue;
color: white;
}

.boxmiddle
{
position: absolute;
top: 140px;
left: 100px;
}

.boxright
{
position: absolute;
top: 180px;
left: 150px;
background-color: red;
color: black;
}

}
</style>

</head>

<body>
<input size=10 id="aa" type="text" class="boxleft" value="a">
<input size=10 id="bb"  type="text" class="boxmiddle" value="b">
<input id="cc"  type="button" class="boxright" value="c button">

<input type="button" value="orig" onclick="javascript:aa.className='boxleft';cc.className='boxright';return false;">

<input type="button" value="switch" onclick="javascript:aa.className='boxright';cc.className='boxleft';return false;">


</body>
</html>

0
 
LVL 5

Expert Comment

by:crimson117
ID: 12388767
Actually cobols works pretty darn well too, as long as you don't have elements positioned with CSS:

<html>
<head>

<style type="text/css">
.boxleft
{

background-color: blue;
color: white;
}

.boxmiddle
{
color: purple;
font-weight: bold;
}

.boxright
{

background-color: red;
color: black;
}

}
</style>

</head>

<body id="bod">
 <input size=10 id="aa" type="text" class="boxleft" value="a">
<input size=10 id="bb"  type="text" class="boxmiddle" value="b">
<input id="cc"  type="button" class="boxright" value="c button">

<input type="button" value="orig" onclick="document.getElementById('bod').style.direction='ltr';return false;">

<input type="button"  value="switch" onclick="document.getElementById('bod').style.direction='rtl';return false;">

</body>
</html>


If you have elements positioned with CSS, the CSS will override the style.direction, and instead only the text-direction inside the input boxes will change.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 12389870
>>>If you have elements positioned with CSS, the CSS will override the style.direction, and instead only the text-direction inside the input boxes will change.

Break the inheritance; of course.  If you have cascades, you have to maintain them.  It is no different for any CSS property they have scope, contraints and inheritance characteristics.


You can scope it from a single element to a page, and you can overlay the styles to ge twhatever effect you want.  That is a primary reason for using CSS.

Cd&
0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question