PDA

View Full Version : ExtJs Help



thilakmsc
6 Jul 2012, 8:28 PM
Here my code i don't what's wrong in that.

buttons: [{text:'Login',handler : function() {
Ext.Ajax.request
({



Ext.MessageBox.alert('Status','Log In Failed!');
}
}
});
}

}, {text:'Reset'}]});
url: 'Default.aspx?type=Login',
method: 'POST',
params:
{
action: 'new',
//modify date
Name:'thilak'
},
waitMsg: 'Saving Data...',
success: function(response)
{
var s = response.responseText;
var respon = response.responseText;
if(respon==1)
{
Ext.MessageBox.hide();
Ext.MessageBox.alert('Status','Logged In Successfully');
window.location = 'Login.php';
}
else
{
Ext.MessageBox.hide();

C# Code :

string action = Request.QueryString["type"];
if (action != string.Empty)

switch (action)

{case "Login":

Response.ContentType = "text/html";
Response.Write(1);

break;
}


But in the i get a Response like :

1

<!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><title>
Untitled Page
</title><link href="ExtJS/resources/css/ext-all.css" rel="stylesheet" type="text/css" /></head>
<body>
<form name="form1" method="post" action="Default.aspx?type=Login" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE0MDkxNzYwNDNkZMqODl+2ksqIiQHUa9wayQUUyTs9" />
</div>

<div>

<script type="text/javascript" language="javascript" src="ExtJS/adapter/ext/ext-base.js"></script>

<script type="text/javascript" language="javascript" src="ExtJS/ext-all.js"></script>

<script type="text/javascript" language="javascript" src="Scripts/default.js"></script>


</div>
</form>
</body>
</html>


Help :

I need to get only one(1) as result

scottmartin
7 Jul 2012, 8:46 AM
Please properly format your code using the code tags so we can read it ..

In looking at your code, you have an ajax statement, but all the properties are listed outside of the call .. is this just a cut/paste error on your part?

Do you see any information sent in your header? do you receive a response at all?

You response is a 1, or all the html you have listed? ...
Did you create the form using html?

Sorry, but you will need to format you post a little better so we can make sense of this is.

Scott.

thilakmsc
8 Jul 2012, 11:04 PM
Really thank you for you reply.
I have one big doubt in Tab (Ext Js).,
Is it possible to show one full page inside the Tab.
Please try to reply with Sample code as soon as possible.

Thank you.

scottmartin
9 Jul 2012, 6:47 AM
Is it possible to show one full page inside the Tab.

Do you want a website page to display, or other components? (grid, form)

Scott.

thilakmsc
9 Jul 2012, 6:53 PM
Dear Scott.,

I wants to show Full web page in tab.

Is it possible to Show in tab wise.For the Example I have Page1,page2 and Page3, I wants to show
Page1 in Tab1,Page2 in Tab2 like.

Thank you.:-|

thilakmsc
9 Jul 2012, 7:08 PM
Dear Scott ,

May i know how to pass Response from Asp.net(C#) to ExtJs page (please give your own example to pass pass the values between Asp.net and ExtJs).

For the Example .,

In button Click I wrote a code like,

ExtJs Code
buttons: [{text:'Login',handler :
function()
{
Ext.Ajax.request
({
url: 'Default.aspx?type=Login',
method: 'POST',
params:
{
action: 'Login',
Name:'thilak'
},
waitMsg: 'Saving Data...',

success: function(response)
{
var s = response.responseText;
var respon = response.responseText;
if(respon==1)
{
Ext.MessageBox.hide();
Ext.MessageBox.alert('Status','Logged In Successfully');
window.location = 'Login.aspx';
}
else
{
Ext.MessageBox.hide();
Ext.MessageBox.alert('Status','Log In Failed!');
}

}

});
}


Aspx.cs Code(In Form load)

string action = Request.QueryString["type"];

if (action != string.Empty)

switch (action)
{
case "Login":
Response.ContentType = "text/html";
Response.Write(1);
break;

}

Response.Write(1);

OutPut (Response)

1

<!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><title>
Untitled Page
</title><link href="ExtJS/resources/css/ext-all.css" rel="stylesheet" type="text/css" /></head>
<body>
<form name="form1" method="post" action="Default.aspx?type=Login" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE0MDkxNzYwNDNkZMqODl+2ksqIiQHUa9wayQUUyTs9" />
</div>

<div>

<script type="text/javascript" language="javascript" src="ExtJS/adapter/ext/ext-base.js"></script>

<script type="text/javascript" language="javascript" src="ExtJS/ext-all.js"></script>

<script type="text/javascript" language="javascript" src="Scripts/default.js"></script>


</div>
</form>
</body>
</html>

scottmartin
10 Jul 2012, 5:27 PM
You can display a webpage in a tab like so:



Ext.create('Ext.tab.Panel', {
width: 300,
height: 200,
activeTab: 0,
items: [
{
title: 'Tab 1',
bodyPadding: 10,
html : 'Select Tab 2 to see our site!'
},
{
title: 'Tab 2',
html : '<iframe src="http://www.sencha.com" width="100%" height="100%" ></iframe>',
}
],
renderTo : Ext.getBody()
});


Scott.

thilakmsc
10 Jul 2012, 7:45 PM
Dear Scott ,

Really thank you for your reply., you really help me to learn ExtJs well. I think i disturb you lot sorry for that.May i know how to pass Response from Asp.net(C#) to ExtJs page (please give your own example to pass pass the values between Asp.net and ExtJs).

scottmartin
11 Jul 2012, 6:18 AM
You server only needs to return JSON as a response:

ex:
{success: true, data: [{ field: value, ... ] }

Scott

thilakmsc
12 Jul 2012, 1:35 AM
Dear Scott.,

Is it possible to show aspx in tab without Iframe.

Thilak

thilakmsc
13 Jul 2012, 9:29 PM
Error Message :

'Unable to parse the JSON returned by the server: You're trying to decode an invalid JSON String: <?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">
{"Table" : [{"UserId" : "1","UserName" : "Thilakraj","DateOfBirth" : "3/21/1985 12:00:00 AM","Gender" : "1","EmailId" : "thilakraj@angleritech.com"},
{"UserId" : "2","UserName" : "thilak","DateOfBirth" : "7/10/2012 12:00:00 AM","Gender" : "1","EmailId" : "thilakraj@angleritech.com"},
{"UserId" : "3","UserName" : "thilaksample","DateOfBirth" : "7/10/2012 12:00:00 AM","Gender" : "1","EmailId" : "thilakraj@angleritech.com"},

</string>'
when calling method: [nsIDOMEventListener::handleEvent]


Filtered chrome url chrome://firebug/content/net/spy.js

Json Data :

{"Table" : [{"UserId" : "1","UserName" : "Thilakraj","DateOfBirth" : "3/21/1985 12:00:00 AM","Gender" : "1","EmailId" : "thilakraj@angleritech.com"},
{"UserId" : "2","UserName" : "thilak","DateOfBirth" : "7/10/2012 12:00:00 AM","Gender" : "1","EmailId" : "thilakraj@angleritech.com"},]}

[B]Code :


Ext.onReady(function () {

Ext.define('Bond', {
extend: 'Ext.data.Model',
fields: ['UserId', 'UserName', 'DateOfBirth', 'Gender','EmailId']
});


var store = new Ext.data.JsonPStore
({
root: 'Table', // see json output
proxy: {
type: 'ajax',
url: '../ExtJs.asmx/UserInformation',
actionMethods: {create: 'POST', read: 'POST', update: 'POST',
destroy: 'POST'},
reader:
{
type: 'jsonp',
root: 'Table',
idProperty: 'UserId'
}
},
model: 'Bond'
// fields: [ {name: 'UserId', type: 'int'}, 'UserName','DateOfBirth','Gender','EmailId']
});

store.load();


var grid = new Ext.grid.GridPanel({

store: store,
columns: [
{header: "User Name", width: 120, dataIndex: 'UserName', sortable: true},
{header: "Date Of Birth", width: 180, dataIndex: 'DateOfBirth', sortable: true},
{header: "Email", width: 115, dataIndex: 'EmailId', sortable: true}
,{header: "Gender", width: 100, dataIndex: 'Gender', sortable: true}
],
stripeRows: true,
autoExpandColumn: 'UserName',
height: 350,
width: 600,
title: 'User Information',
stateful: true,
stateId: 'grid'
});

store.load();

grid.render('grid-example');
});

scottmartin
13 Jul 2012, 9:54 PM
As mentioned several times...
Please properly format your code using the code tags so we can read it ..

As for the error .. is your server using json encode to return the json string?

Scott.

thilakmsc
13 Jul 2012, 10:03 PM
Dear Scott ,

No, It's only convert the dataset to Json string.