postback cann't get the value of the server-side control checkbox correctly

Jun 1, 2009 at 5:40 AM

postback cann't get the value of the server-side control checkbox correctly ?

 

 <fjx:FileUploader ID="FileUploader1" runat="server"
                                    AllowedFileTypes="compress file(zip,rar):*.zip;*.rar;"
                                    ImagesPath ="~/images/uploader/"
                                    BrowseButtonUrl="Browse.png"
                                    BrowseButtonOverUrl="BrowseOver.png"
                                    BrowseButtonPressedUrl="BrowsePress.png"
                                    BrowseButtonDisabledUrl="BrowseDisabled.png"
                                    UploadButtonUrl="Upload.png"
                                    UploadButtonOverUrl="UploadOver.png"
                                    UploadButtonPressedUrl="UploadPress.png"
                                    UploadButtonDisabledUrl="UploadDisabled.png"
                                    CancelButtonUrl="Cancel.png"
                                    CancelButtonOverUrl="CancelOver.png"
                                    CancelButtonPressedUrl="CancelPress.png"
                                    CloseButtonUrl="images/uploader/CloseButton.gif" CssUrl="~/css/uploader.css"
                                    JsFunc_FileStateChanged="FileStateChanged"
                                    MaxFileNumberReachedMessage="Only on file to be choosed!"
                                    MaxFileQueueSizeReachedMessage="Filesize more than 500M."
                                    MaxFileSizeReachedMessage ="Filesize reached the max size 500M."
                                    RequestAsPostBack="true"
                                    MaxNumberFiles="1"
                                    MaxFileSize="500M"
                                    MaxFileQueueSize="500M"
                                    >
                                    <Adapters>
                                        <fjx:FileSaverAdapter Runat="server" FolderName="files/compressfile" OnFileNameDetermining="FileNameDetermining"/>
                                    </Adapters>
                                </fjx:FileUploader>

<asp:CheckBox ID="cbxOrderByName" runat="server" Text="Sort by name ASC" />

back code : 

UploadFileInfo uploadInfo = new UploadFileInfo();

uploadInfo.SortByImageName = cbxOrderByName.Checked;

the value of the cbxOrderByName control comes "true" always .

and There is another question , I cann't get the queringstring from current Request object.

http://localhost:2929/BitAuto.BusiPlat.Albums.Website/ImageUploadZip.aspx?cid=11153 

string returnUrl = Request.QueryString["cid"]  ;

the returnUrl will come "null"

 

Coordinator
Jun 1, 2009 at 4:23 PM

Just a quick tip: when you have problem like that, try to isolate the problem on a separate web page and just then ask the question why something is not working.

Jun 2, 2009 at 4:01 AM

I have done that , the problem still occurs .

Only I cann't get the value of the checkbox and radiobutton 's value correctly. So I do save the checkbox and radiobutton 's value to a hiden input field . I can get the value correctly by the hiden fields , when the page postback .

I am not sure Is it a bug here .

 

thaks.

Coordinator
Jun 2, 2009 at 4:56 AM

I just tested your example and I have absolutely no problem getting the checkbox state. 

When I say that you don't try to isolate your problem, I mean it. 

The most important thing when you resolv any kind of problem in the software development is to isolate it. If you can't, then the most simple problems will look to you as enormous.

 

Jun 3, 2009 at 2:06 AM

test.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <fjx:FileUploader ID="FileUploader1" runat="server" RequestAsPostBack="true">
        </fjx:FileUploader>
        <asp:CheckBox ID="CheckBox1" runat="server" />
    </div>
    </form>
</body>
</html>

 

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using com.flajaxian;

test.aspx.cs:

public partial class test : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void FileNameDetermining(object sender, FileNameDeterminingEventArgs args)
    {
        bool isChecked = CheckBox1.Checked;
    }
}

the varialbe isChecked's value is always to be "true" , I didn't know why . Or could you send me your code . liurongwei2008@gmail.com

thank you very much .

 

Coordinator
Jun 3, 2009 at 7:46 AM

Your example is technicly speaking not complete, as it should be

<fjx:FileUploader ID="FileUploader1" runat="server" RequestAsPostBack="true">

   <Adapters>

      <fjx:FileSaverAdapter Runat="server" FolderName="files/compressfile" OnFileNameDetermining="FileNameDetermining"/>

   </Adapters>

</fjx:FileUploader>

But you were right on the level of FileNameDetermining event the value wasn't set.

Please get the latest version where that is fixed.

Jun 3, 2009 at 8:26 AM

Oh , I missed to paste the event property.

Ah, Ok ,I will get it .

thanks a ton . Hope the control became stronger and perfect .

Jun 4, 2009 at 3:39 AM

the latest version my have some problem remainly.

Flajaxian.requestAsPostBack = function(uploader, array) {
    var form = Flajaxian.findFirstPostForm();
    if (!form) { return; }
    for (var i = 0; i < form.elements.length; i++) {
        var element = form.elements[i];
        var tag = element.tagName.toLowerCase();
        if (tag == "input" && (element.type.toLowerCase() == "checkbox" || element.type.toLowerCase() == "radio") && !element.checked) continue;
        var val = (tag == "select" && element.selectedIndex >= 0)
                        ? element.options[element.selectedIndex].value : element.value;
        if (typeof val != "undeined") array.push({ key: (element.name || element.id), value: val, fileID: 0 });
    }
}

val!="undefined" should be .

I have tested , checkbox's value still invaliable . 

what should form ecrypt attribute to be ?

Coordinator
Jun 4, 2009 at 5:14 AM

Yeah sorry, there was that typo. I made also a few other corrections. Here is a test page for you. Put a break point in the FileNameDetermining method to test.

<%@ Page Trace="true" language="c#" AutoEventWireup="false" %>
<%@ Register TagPrefix="fjx" Namespace="com.flajaxian" Assembly="com.flajaxian.FileUploader"%>
<SCRIPT language="C#" runat="server">
private void FileNameDetermining(object sender, EventArgs e)
{
  bool isChecked1 = CB1.Checked;
  bool isChecked2 = RB1.Checked;
  string val = DDL1.SelectedValue;
}
</SCRIPT>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
<fjx:FileUploader ID="FileUploader1" runat="server" 
    RequestAsPostBack="true">
    <Adapters>
        <fjx:FileSaverAdapter FolderName="UploadFolder" OnFileNameDetermining="FileNameDetermining"/>
    </Adapters>
</fjx:FileUploader>

<asp:CheckBox ID="CB1" runat="server" Text="Sort by name ASC" />

<asp:RadioButton ID="RB1" runat="server" Text="Sort by name ASC" />

<asp:DropDownList ID="DDL1" runat="server">
    <asp:ListItem Text="1" Value="1"></asp:ListItem>
    <asp:ListItem Text="2" Value="2" Selected="True"></asp:ListItem>
    <asp:ListItem Text="3" Value="3"></asp:ListItem>
</asp:DropDownList>
     </div>
    </form>
</body>
</html>