user2349354
user2349354

Reputation: 21

Pass values + upload file

I am using asp.net c# and Telerik tools. My question is, I am tring to pass the values

of (textbox, drop down list and file uploaded details) to another asp page using java script, however nothing work and I want to get the file content and pass it as well ?? can you give me a solution? please!

on page1:

<script type="text/javascript">
               function GetRadWindow() {
                    var oWindow = null;
                    if (window.radWindow) oWindow = window.radWindow;
                    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
                    return oWindow;
               }
               function populateCityName(arg) {
                   var cityName = document.getElementById("cityName");
                   cityName.value = arg;
               }
                function returnToParent() {
                    //create the argument that will be returned to the parent page
                    var oArg = new Object();

                    //get the city's name           
                    oArg.cityName = document.getElementById("cityName").value;
                    //get a reference to the current RadWindow
                    var oWnd = GetRadWindow();




                    //Close the RadWindow and send the argument to the parent page
                    if (oArg.cityName) {
                        oWnd.close(oArg);
                    }
                    else {
                        alert("Please fill field");
                    }
                }
          </script>

page 2:

 function OnClientClose(oWnd, args) {
                //get the transferred arguments
                var arg = args.get_argument();
                if (arg) {
                    var cityName = arg.cityName;

            $get("order").innerHTML = "You chose to fly to <strong>" + cityName + "</strong>";
                }

Upvotes: 2

Views: 723

Answers (3)

Jeff Fritz
Jeff Fritz

Reputation: 9861

There are Telerik-specific APIs that will help you with passing data from the RadWindow to a parent window, and you can reload the uploaded file content using the AjaxManager.

Consider this sample that demonstrates how to pass values back from the RadWindow to the owning page: http://demos.telerik.com/aspnet-ajax/window/examples/clientsideevents/defaultcs.aspx?product=window

Upvotes: 0

Dolo
Dolo

Reputation: 976

Try using
var cityName = document.getElementById('<%= cityName.ClientID %>'); instead of

var cityName = document.getElementById("cityName");

Upvotes: 1

Manish Mishra
Manish Mishra

Reputation: 12375

you can create a Session variable to store uploaded fileContent and access it on another page.

For simple text like value of a TextBox or a dropdown, you can directly send them through querystring.

Create a Session Variable like this.

page1.aspx.cs

Session["FileContent"] = FileUpload1.FileContent;

and access it on another page like below;

page2.aspx.cs

if(Session["FileContent"]!=null)
{
    Stream fileData = (Stream)Session["FileContent"];

    StreamReader reader = new StreamReader(stream);
    string imgData = reader.ReadToEnd();

    //save imgData to db
}

you cannot access other pages control value through javascript.
if you don't get anything by doing this document.getElementById("cityName"), then that simply means, no such control with the id exist on this page.

Try passing TextBox text using queryString (or Session variable).

Upvotes: 0

Related Questions