This is a migrated thread and some comments may be shown as answers.

show/hide radbutton as per the value entered on radtextbox

7 Answers 399 Views
Input
This is a migrated thread and some comments may be shown as answers.
axxo
Top achievements
Rank 1
axxo asked on 06 Mar 2014, 10:23 PM
1. i have one radtextbox and radbutton. i want to make this radbutton visible when people start typing. if there is no values in the radtextbox radbutton should be hidden. so when started entering the letters radbutton should be visible and when they delete or backspace completely then radbutton should be hidden?
i tried so many ways to achieve this task from client side.

what is the java script code for this one. it should support all browsers. i tried onkeypress. but didnt get the result i want.


2. i want when user remove selected files from radasyncupload then radbutton should be hidden. when they start selecting files to upload then radbutton should b visible.
 when i selected removeselectedfiles option, button become hidden immedieately remove just one file itself. hwo to check the number of files selected in radasyncupload from client side ?

3. is there any textboxlist control in telerik for email text field? i want like to see as iphone, facebook and all. how to do that?


7 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 07 Mar 2014, 05:24 AM
Hi,

As for your first Question try to attach both OnkeyPress and onKeydown event to the RadTextBox as follows.

ASPX:
<telerik:RadTextBox ID="RadTextBox1" runat="server" ClientEvents-OnKeyPress="OnKeyPress"
    onkeydown="Key(this,event);">
</telerik:RadTextBox>
<telerik:RadButton ID="RadButton1" runat="server" Text="Submit" Enabled="false">
</telerik:RadButton>

JavaScript:
function Key(sender, keycode) {
    if (keycode.keyCode == 8) {
        if (sender.control.get_textBoxValue() == "") {
            var btn = $find("<%=RadButton1.ClientID %>");
            btn.set_enabled(false);
        }
    }
}
function OnKeyPress(sender, args) {
    if (args.get_keyCharacter() != "") {
        var btn = $find("<%=RadButton1.ClientID %>");
        btn.set_enabled(true);
    }
}

For your second second question, you can use the OnClientFileSelected event to enable the button and OnClientFileUploadRemoved event to disable the button. For getting the selected files count from client side you can use a Global variable and increment one to it in OnClientFileSelected event and OnClientFileUploadRemoved event decrement one from that global variable. Please have a look into the sample code snippet which works fine at my end.

ASPX:
<telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" OnClientFileSelected="OnClientFileSelected" OnClientFileUploadRemoved="OnClientFileUploadRemoved">
</telerik:RadAsyncUpload>
<telerik:RadButton ID="RadButton1" runat="server" Text="Submit" Enabled="false">
</telerik:RadButton>

JavaScript:
var selectedfile=0;
function OnClientFileSelected(sender, args) {
    selectedfile++;
    var btn = $find("<%=RadButton1.ClientID %>");
    btn.set_enabled(true);
}
function OnClientFileUploadRemoved(sender, args) {
    var btn = $find("<%=RadButton1.ClientID %>");
    btn.set_enabled(false);
    selectedfile = selectedfile-1;
    alert("Number of Selected Files:" + selectedfile);
}

I am not sure about your third question. Can you please elaborate your requirement?

Thanks,
Shinu.
0
axxo
Top achievements
Rank 1
answered on 07 Mar 2014, 06:38 AM
thank u very much. ill try that code.
since im using multiple file selection i was using onclientfilesselected. so what is the difference between onclientfileselected and OnClientFileSelected ? why you preferred for OnClientFileSelected ?

my third question is about textboxlist. i dont know whether to call that like that. its like if you enter email id in text box it will show that in a block with close button.im attaching the imagefile what im mentioning.

4. IE 11, asyncupload not selecting mulitiple files. why? i can only select individual files.
5. whch is the best option to save content type. i used asyncupload the content type to save it to database. but while downloading some of the files downloading without extension. what to do in this case?


0
axxo
Top achievements
Rank 1
answered on 08 Mar 2014, 06:21 PM
thnx shinu.
ur code really worked for my purpose.

i made some changes. instead of disable/enable i used visibility option
now my problem is related to content type. its not getting the correct content type.

what is ur suggestion to get the correct content type.

2. also IE 11 doesnt not allow multiple selection of files.

3. Textboxlist is available for email fields or not?
0
Shinu
Top achievements
Rank 2
answered on 10 Mar 2014, 09:44 AM
Hi,

The OnClientFileSelected client side event occurs when a file is selected in a file input control and OnClientFilesSelected  occurs when files are selected. Please take a look into the following help documentation to know more about this events.
OnClientFileSelected
OnClientFilesSelected

As for your next question IE11 supports multiple file selection. Please try the following code snippet which works fine at my end.

ASPX:
<telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" MultipleFileSelection="Automatic">

As for your next question about Content Type, please have a look into the c# code to access the Content Type of uploaded file.

C#:
protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
{
    //content type of the uploaded file
    string contenttype = e.File.ContentType;
}

For your Last question there is a control called RadAutoCompleteBox to achieve your scenario. Please have a look into the following code snippet and attached screen shot.

ASPX:
<telerik:RadAutoCompleteBox runat="server" ID="RadAutoCompleteBox1" DataSourceID="SqlDataSource1" DataTextField="EmailId" DataValueField="EmailId" Filter="StartsWith">
    <DropDownItemTemplate>
        <table>
            <tr>
                <td>
                    <%# DataBinder.Eval(Container.DataItem, "EmailId")%>
                </td>
            </tr>
        </table>
    </DropDownItemTemplate>
</telerik:RadAutoCompleteBox>

Hope this will helps you.
Thanks,
Shinu.
0
axxo
Top achievements
Rank 1
answered on 10 Mar 2014, 11:42 AM
1. Sorry shinu. its not IE 11 it IE8
IE 8 not selecting multiple selection.

2. There was some coding errors when i was using radasyncupload to get content type. i was using different way to get the content type. but i found still content type is blank for dwg,dwf(CAD files). im facing problem when i downloading files with mozilla firefox 27.0.1. its downloading files without extension. may i know the reason. In IE its working fine.

3. Ill check about RADAutocompletebox.



0
axxo
Top achievements
Rank 1
answered on 10 Mar 2014, 12:02 PM
RADAUTOCOMPLETE:

I checked the control. i dont want it connect to database. all i want is that user need to enter the email IDs as they wish. but it should behave afterwards as you shown in ur screenshot. but i dotn want it to check with database or filter from database.
0
Shinu
Top achievements
Rank 2
answered on 11 Mar 2014, 06:24 AM
Hi,

Please make sure that you have Silevrlight/Flash installed in IE8, before try to multiple select. With RadAsyncUpload it is possible to select multiple files. This can be achieved by setting the MultipleFileSelection="Automatic" property. Multpile file selection is possible only when FileApi, Silverlight or Flash upload module is used.

As far as my knowledge RadAutoCompleteBox will only work with DataBase and using RadTextBox we cannot achieve this functionality.

Unfortunately I couldn't find any issue with the ContentType of CAD files. As a work around please try the following C# code snippet which works fine at my end.

C#:
protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
{
    //content type of the uploaded file
    string contenttype = string.Empty;
    string extension = e.File.GetExtension();
    if (extension == ".dwg" || extension == ".dwg")
        contenttype = "CAD";
    else
        contenttype = e.File.ContentType;
}

Thanks,
Shinu.
Tags
Input
Asked by
axxo
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
axxo
Top achievements
Rank 1
Share this question
or