PDA

View Full Version : [CLOSED] Show Button ONLY in certains case



Mario
Jan 20, 2015, 11:52 AM
In this code:



<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>

<html>
<head runat="server">
<title></title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:Window runat="server" Width="200" Height="70" Title="Insert value..." Closable="false" Layout="Form" BodyPadding="5">
<Items>
<ext:TextField runat="server" FieldLabel="Number:" LabelWidth="50" >
<RightButtons>
<ext:Button runat="server" ID="ButtonTest" Icon="Add" />
</RightButtons>
</ext:TextField>
</Items>
</ext:Window>
</form>
</body>
</html>



How do you show the button "ButtonTest" only if you press the key "1" ?
In all other cases the button "ButtonTest" must be hidden.

Dimitris
Jan 20, 2015, 2:26 PM
Do you mean, only when the value of the TextField is 1 or every time user inputs 1?

Sergei
Jan 20, 2015, 2:53 PM
Hi all!

I have a solution to the issue for the case, if user press key "1".


<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>

<html>
<head runat="server">
<title></title>
<script type="text/javascript">
var keyFn = function (el, e) {
if (e.button == '48') {
App.ButtonTest.show();
}
else {
// something
}
return false;
};
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:Window runat="server" Width="200" Height="70" Title="Insert value..." Closable="false" Layout="Form" BodyPadding="5">
<Items>
<ext:TextField runat="server" FieldLabel="Number:" EnableKeyEvents="true" LabelWidth="50" >
<Listeners>
<KeyPress Fn="keyFn" />
</Listeners>

<RightButtons>
<ext:Button ID="ButtonTest" runat="server" Icon="Add" Hidden="true" />
</RightButtons>

</ext:TextField>
</Items>
</ext:Window>
</form>
</body>
</html>

Mario
Jan 20, 2015, 4:53 PM
Tnk Sergei !!!

It's OK.