Sunday

show hide javascript

Here is sample how to show hide, control in asp.net/javascript
let say we have ddBerechnung control and we have to hide controls when this dropdown has value 'identisch'

server side will have this :
         
protected override void OnPreRender(EventArgs e)
{
ddBerechnung.Attributes.Add("onChange", "ShowHidePercentField(this)");
}


and aspx will have this javascript:
         
function ShowHidePercentField(cb){
var selIdx = cb.selectedIndex;
var newSel = cb.options[selIdx].text;
var textBox=document.getElementById('<%=txtBerechnung.ClientID%>');
var Runden= document.getElementById('<%=ddRunden.ClientID%>');
var RundenSpan= document.getElementById('RundenSpan');


if (trim(newSel)=='identisch'){ ///
textBox.style.display="none";
Runden.style.display="none";
RundenSpan.style.display="none";

}else{
textBox.style.display="";
Runden.style.display="";
RundenSpan.style.display="";

}

}

///.... at the end of control
<script language='javascript'>
var elem=document.getElementById('<%=ddBerechnung.ClientID%>')
ShowHidePercentField(elem);
</script>

more...

No comments:

test smtp server with powershell

Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...