Click here to Skip to main content
15,884,537 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
I want to stop rendering of a client side control dynamically and visa verse,

Such like:
first I have
HTML
<html>
<body>
<!-- <my control="" /> -->
<input type="submit" value="submit"/>
</body>
</html>


And I need following after button click:
HTML
<html>
<body>
<my control="" /> 
<input type="submit" value="submit"/>
</body>
</html>
Posted
Updated 7-Sep-11 21:58pm
v2

Why you are not trying it using Java Script ?
Add and Remove HTML elements dynamically with Javascript[^]
 
Share this answer
 
You can use javascript for that, just make a function

JavaScript
function Display()
{
 document.getElementById('showcontrol').style.display = 'block';
}


and call that on button click, like this

HTML
<html>
<body>
<my id="showcontrol" control="" style="display: none;" /> 
<input type="submit" value="submit"  önclick="Display()" />
</body>
</html>


[UPDATE]

try this:
XML
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--Hide from old browsers
var i=0,j=0;
var t1= new Array();
function createtext(){
i++;
t1[i]=document.createElement('input');
t1[i].type='text';
t1[i].name='text'+i;
t1[i].value = "hello";
t1[i].size = 10;
document.forms[0].appendChild(t1[i]);
var mybr=document.createElement('<br>');
document.appendChild(mybr);
}
</SCRIPT>
</HEAD>
<BODY >
<form action="" method="get" name="f1">
<input name="b1" type="button" onClick="createtext()" value="new text">
</form>
</BODY>
</HTML>


Refer this [^]for further reading.

hope it helps :)
 
Share this answer
 
v3
Comments
Tushar Parmar 8-Sep-11 4:22am    
by using this method,

the control renders on page,
but i want it like the control should not be available on page,

means i need that firebug should not be able to find control after i hide it.
Uday P.Singh 8-Sep-11 5:22am    
okay then see the link posted by Abhijit and i will update the answer
Tushar Parmar 8-Sep-11 8:34am    
hi uday,
i know this method of generating dynamic table,

but i want is as ,

there is a asp user control as control already in page with comment(<!-- -->),
at run time i don't want that control to appear,
but after selecting that button, the comment should be eliminated, so that the user control appears, and same for its reverse,

the control is already there on page,
Uday P.Singh 9-Sep-11 3:58am    
In my updated answer, on the button click you will create a new textbox in the same way you can create any other html control. And this is the approach we usually follow to create controls at run time.

And what you are saying about applying comments and removing comments at run time is not a coding practice to follow. Don't get confuse!
by using this method,

the control renders on page,
but i want it like the control should not be available on page,

means i need that firebug should not be able to find control after i hide it.
 
Share this answer
 
Comments
Abhijit Jana 8-Sep-11 4:14am    
Did you check the link that I have provided.

Please don't post your query as solution. Post as comments so that OP can get a notification.
Tushar Parmar 8-Sep-11 4:17am    
ok,

i am unable to open that link because firewall security,
can u send me another link!!!!
try doing this

To add/remove the control

HTML
<html>
<script language="javascript">
 $("#btn1").toggle(function(){
$(".todelete").remove();
},function(){
$("body").prepend('<my control="" class="todelete" />');
});
</script>
<body>
<my control="" class="todelete" />
<input type="button" id="btn1" value="click to toggle control">
<input type="submit" value="submit"/>
</body>
</html>


I hope I was able to solve your problem.

Watch my first article posted on codeproject and comment and vote:
http://www.codeproject.com/KB/HTML/speechinputapi.aspx
or http://blog.robinrizvi.info

Drop me a mail for any comments, suggestions or questions.
mail@robinrizvi.info
 
Share this answer
 
v2
Comments
Tushar Parmar 9-Sep-11 4:06am    
i was finding it from last 4 days,
thank you so much Robin....
Robin Rizvi 9-Sep-11 12:44pm    
Happy to help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900