Showing posts with label website. Show all posts
Showing posts with label website. Show all posts

Monday, March 26, 2012

Prerequisites at ASP.NET Hoster for Atlas

My sites are hosted by a normal ASP.NET (2.0) hoster. Do I need any prerequisites on the hosted machine to enable Atlas on my website?

Thanks

Ralf

As of the March release Atlas should work fine as a medium trust application. Therefore you should be able to simply xcopy your Atlas app to the server.

One problem you may face however is that your host does not map the new ".asbx" extension (which is used for webservice bridge files). This means you can probably not use this feature until your host would add this mapping.

Here is additional material on .asbx files and how to route bridge calls through an .axd extension without having to register the .asbx extension with IIS, great for a hosted account.

http://atlas.asp.net/docs/Walkthroughs/DevScenarios/bridge.aspx
http://atlas.asp.net/docs/atlas/doc/bridge/tunnel.aspx

thanks
-jhawk


Thanks for the answer. I will try it out.

Saturday, March 24, 2012

Problem calling webservice from client code

Hi All,

I am trying to call a webservice method on a ASP.NET page (in AJAX enabled website). I have my asmx file in the same project as my ASP.NET page. When i try to compile the project , i am getting a "Could not create type TestService" error. Can some body tell me what exactly is the problem here?

Thanks

Mahesh

Confused cud u have given namespace reference of web.script.services.scriptservices

as using web.script.services.scriptservices

& inherite [ScriptServices]


Thanks for the reply ranjeet. But i don't really get the gist of your message , can you please be more clear? I am copying my webservice code below for your reference:

using System;

using System.Web;

using System.Collections;

using System.Web.Services;

using System.Web.Services.Protocols;

using System.Web.Script.Services;

using System.Data.SqlClient;

using System.Data;

///<summary>

/// Summary description for TestService

///</summary>

///

namespace MyTestService

{

[WebService(Namespace ="http://tempuri.org/")]

[WebServiceBinding(ConformsTo =WsiProfiles.BasicProfile1_1)]

publicclassTestService : System.Web.Services.WebService

{

[WebMethod]

[ScriptMethod]

publicDataSet GetEmployeeDetails(int empID)

{

String strConnectionString =String.Empty;

String strQuery ="Select * from Employee where EmployeeID = " + empID; ;

strConnectionString ="Server=PC21172\\SQLEXPRESS;Database=EmployeeDB;user=sa;pwd=pwd";

//Get the employee details for the passed id

SqlConnection c =newSqlConnection(strConnectionString);

c.Open();

SqlDataAdapter dataAdapter =newSqlDataAdapter(strQuery, strConnectionString);DataSet dsEmployeeDetails =newDataSet();

dataAdapter.Fill(dsEmployeeDetails);

return dsEmployeeDetails;

}

}

}

Thanks

Mahesh


The DataSet and DataTable is supported in the v1.0. You have add the preview version.


Hi,

I have infact downloaded the January CTP and i am able to return the datatable. Now th issue is , how can i bind the datatable or dataset that i return from the webservice to a ASP.NET datagrid control in javascript call back function. Can somebody help me on this?

Thanks

Mahesh


The Asp.net DataGrid/GridView does not have any objectmodel in the client side. Few days back I wrote a component which does the exact thing, Checkout the following article:http://dotnetslackers.com/articles/ajax/ASPNETAjaxGridAndPager.aspx

Problem displaying AjaxControlToolkit website

Hi,

i've created an AjaxControlToolkit website (from a template).

to see that all is working well i've added a TextBox and watermark to it.

everything works greate here... at my computer... but...

when i uploaded it to my domain hosting space the toolkit is not functioning. all Ajax extension features are working but the toolkit features aren't!

and the "funny" part is that i don't get any error - client side nor server side...

any ideas?!?!?

i made sure the latest Ajax extension is installed on my host server and a restart to the machine was performed (even though it was not required)

any help will be appreciated...

Thanks!

Is the toolkit dll installed on the server correctly? Where is it located? In the gac or in the web app bin directory?
The dll is only located at my Bin directory. where else should it be?
Do a View | Source on the page coming off the server and compare it against the local version - that may help show what's not hooked up right.

problem in ajax website

hi

i am facing a problem in creating Ajax website.

When i am takingAjax enabled website option i am able to do everything fine.

But when i am taking a create Website option i am getting error . I have also includedScriptManager on the page which is required by most of the Ajax Controls to work properly.

Thanx in advance

Hi.

When you create an Ajax-enabled web site, the WEB.Config file created contains config section, HTTP handlers, HTTP modules all needed by AJAX.

One example is that the ScriptManager creates a call for javascript called ScriptResources.axd where axd is not known extension for your web-server
(unlike ASPX, ASMX, JS, ASHX etc.) The httpHandler section includes this extension and set it to be handled by AJAX extension (System.Web.Extensions.DLL file)

What you should do (especially when adding AJAX capability to an existing site) is to copy these additions to your web.config file from an "AJAX-Enabled"
web site. Then you won't e having these errors.


Problem in Ajax i My ASP.Net WebSite

hi

i am working on my website.(when i created website,i don't select Ajax Enabled Template and it is a default asp.net website)

and i want add ajax feature to my website by drag ScriptManager and UpdatePanel from toolbox.but when i run my website,error shown in IE statusBar.

how to solve my problem ?

should i create new website as Ajax enabled template ?

thanks

Hello,

Make sure you install Ajax on your system, and you need to modify your web.config file.

The best way to modify the config file is, create new ajax project, which will built a web.config file for you.

You then compare your old web.config file with the ajax website web.config file. If you haven't added any information to your old web.config file, I would just copy the ajax web.config file to your current (web) project. And if you already added information into your web.config file, then just copy whatever you don't have from the ajax web.config file to yours.

I hope you understand what I'm talking about =)

WS

Problem in Cascading Drop Down

I have created a website using Cascading DropDown in AJAX control tool kit......

I have 3 DropDown lists.....and the list in 2nd one is populated when an Item from 1st DropDown List is selected...Similarly 3rd DropDown is populated depending on 2nd list.....

My problem is that I get all my values in dropdown 3 list but I wanted to show the whole list of items in my result.....means suppose at the end of the selection I have 3 items in DropDown list 3 then all the items in tat list shud be my result......

can u tell me how to extract tat all the items from DropDown list 3 and display it.....

Hi Hemil,

Based on my understanding, there are three DropDownlists in the page. The second DropDownList is bound according the item selected in the first DropDownList. The third DropDownList is bound according the item selected in the second DropDownList. Now you want to know how to get all the items of third DropDownList. In one word, you want to know how to get a DropDownList's items. If I have misunderstood you, please feel free to let me know.

To get all the items of DropDownList, you should use loop to get them.

To better understand your question, could you please confirm the following information:

If you want to get the value of item, the code should like as follows:

string strResult ="";foreach (ListItem itemin DropDownList1.Items) { strResult += item.Value; } 


Ya u got my problem rite but only thing is that I have all the items in Drop Down list 3 which is populated according to the Items selected from Drop Down1 and Drop Down2.....

So after selecting items from DropDown 1 and 2 I get my result in Drop down 3 Which I need to display all at once.....means all items in drop Down list 3.....

So watever code U gave me will work or no and if yes will it work if i change the item in Drop Down 1 or 2 accordingly Dropdown 3 will change so will it append to the Display result.......I have used Cascading Dropdown of AJAX Control tool kit......

<ajaxToolkit:ToolkitScriptManager ID="ScriptManager1" runat="server" /
<asp:DropDownList ID="DropDownList1" runat="server"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList
<ajaxToolkit:CascadingDropDown ID="CascadingDropDown1" runat="server"
ServiceMethod="GetDropDownContents"
UseContextKey="True"
Category="major"
LoadingText="[Loading majors...]"
PromptText="Degree Major/ Program Name"
ServicePath="MajorsDatabase.asmx"
TargetControlID="DropDownList1">
</ajaxToolkit:CascadingDropDown>

<br /><br />

<asp:DropDownList ID="DropDownList2" runat="server"
OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged">
</asp:DropDownList>

<ajaxToolkit:CascadingDropDown ID="CascadingDropDown2" runat="server"
ParentControlID="DropDownList1"
Category="type"
ContextKey="[Loading major types...]"
PromptText="Degree Major/ Program Type"
ServiceMethod="GetDropDownContents"
ServicePath="MajorsDatabase.asmx"
TargetControlID="DropDownList2">
</ajaxToolkit:CascadingDropDown
<br /><br /
<asp:DropDownList ID="DropDownList3" runat="server"
OnSelectedIndexChanged="DropDownList3_SelectedIndexChanged" Visible="true">
</asp:DropDownList>

<ajaxToolkit:CascadingDropDown ID="CascadingDropDown3" runat="server"
ParentControlID="DropDownList2"
Category="campus"
ContextKey="[Loading campus names...]"
PromptText="Campus"
ServiceMethod="GetDropDownContents"
ServicePath="MajorsDatabase.asmx"
TargetControlID="DropDownList3">
</ajaxToolkit:CascadingDropDown>


Hi Hemil,

The code I posted above is only a simple example, which tells you how to loop the DropDownList. You can use different way to display the result according your requirements.

I hope this helps.


Sir,

I tried implementing ur code but I get only the value which is selected item in Drop Down instead of all the values in DropDown List 3......

I will tell you something more on this...I want to display the result after I select Item in Drop Down List 2.......means as soon as I select one item from Drop Down List 2 and then I should press Submit button so It should give me all the values contained in Drop Down list 3 which I will make Invisible to the user.....So in short there is dropDown list behind the scenes which has all the values in DropDown list........I want to display all the Items in dropdown list 3........after I press Submit button......

So the sequence of operations will be.....

1. Select one item from DropDownlist 1

2. As per the selection in dropdown list 1, Drop Downlist 2 will be populated with values so Select item from drop down List 2.

3. Now behind the scenes I have drop down list 3 but I dunt want to show the DropDown....it has all the Items which I need to display to the user...

4. There is one Submit button which I have to press and it should show all the Items from Drop DOwn list 3...which is present behind the scenes...

Thanks,

hemil.



Hi Hemil,

Thanks for your response.

Based on my understanding about your response above, you should bind the DropDownList3 and then loop this DropDownList3 to display Values in the Button event.

The code of Button event should like as follows:

protected void Button1_Click(object sender, EventArgs e) {//Bind DropDownList3 by the item selected in the DropDownList2 DropDownList3.DataSource = YourDataSource; DropDownList3.DataTextField ="DisplayField"; DropDownList3.DataValueField ="ValueField"; DropDownList3.DataBind();string strResult ="";//loop DropDownList3foreach (ListItem itemin DropDownList3.Items) { strResult += item.Value; } }


I hope this helps.


Hi Hemil,

If you have any question, please post them here and don't need to email me directly. We are glad to help you. If you post the question here, other kindly people will help you too. Thanks for your understanding.

Based on your question and the codes you sent to me, you cannot bind the XML file to DropDownList directly. You should read the XML file to a DataSet or XmlDataSource and bind the DropDownList with the data source.

The code should like as follows:

<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList3" runat="server">
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/XMLFile.xml"></asp:XmlDataSource>

</div>
</form>

protected void Button1_Click(object sender, EventArgs e) { XmlDataSource1.XPath ="/MajorsDatabase/major/type";// Use xpath to filter data you want to display. DropDownList3.DataSource = XmlDataSource1; DropDownList3.DataTextField ="name"; DropDownList3.DataValueField ="name"; DropDownList3.DataBind(); }

I hope this helps.


The code is working ... Thanks ...

But I am facing a new problem ... which is ,.... when I select the first and second drop down box .. I get all the names of the campuses ... where as ... it should display me only campus names depending on the DDL1 and DDL2 selection ...

i.e. DDL => DropDownList

When I select from DDL1 - "Acturial Science"

and DDL2 - "b" ... it should give me only ... Campus Name as "San Jose" and "San Diego".

but it is giving all the Campus name from the XML file under the tag "campus" ...

Is there any way we can query the DataBinding or DataSource ...

Thanks.....


Hi Hemil,

You should add XPath to filter the data you want to display.

For example, If you want to get the type names, which are the child node of major node and this major node's name property is "Advertising", the XPath should like as follow:
XmlDataSource1.XPath = "/MajorsDatabase/major[@.name='Advertising']/type";

So you can write the XPath to filter the data. For more information, seeXmlDataSource.XPath Property.


I hope this helps.


Good Afternoon,

Thanks a lot for the guidance... the code works just perfect for the Static values.

I would like to ask you few things like ...

1. can we pass dynamically selected arguments in Xpath ?

2. do we need to write a query for this dynamic invocation ?

I was trying ...

XmlDataSource1.XPath ="/MajorsDatabase/major [DropDownList1.SelectedItem.Text] /type[DropDownList2.SelectedItem.Text]/campus";

But is is not working ...

As we are selecting Major from DDL1 and Type from DDL2 ... I would like to pass those dynamically selected values in XPath ....

I was also trying ...

int one = 1, two = 1;

XmlDataSource1.XPath ="/MajorsDatabase/major[one] /type[two]/campus"; ====> Not working ... where as if we write

XmlDataSource1.XPath ="/MajorsDatabase/major[1] /type[1]/campus"; ====> works ...

Thanks Again ...


Hi Hemil,

Yes, we can pass parameters to XPath dynamically and easy. Since the parameters are variables, we cannot write them in the XPtah string directly. We should use plus to connect the XPath and parameters.

For example:

string strParameter ="Advertising"; XmlDataSource1.XPath ="/MajorsDatabase/major[@.name='"+strParameter+"']/type";


I hope this helps.


Thanks very much for all your help.

Code is working fine.

Wednesday, March 21, 2012

Problem in deployment of AJAX enabled website

Hello Everybody:

Recently I have installed ajax extension in VS2005. I have a asp.net 2.0 website and I made necessary change in the web-config file for the ajax extension as described in AJAX video tutorial in this website. It works fine but when I deploy it to my server then it finds error in web-config file related to missing dll. What can I do? Please give me a suggestion.

Thanks to all.

The ajax installer puts the dlls into the GAC. Because of this, they do not deploy with your app in the bin folder.

You need to also install ajax on the server you are deploying to.


Well, the only things you can do are:

Install the Ajax Extensions on your server! If it is a shared hosting company contacting them may help: I succeeded once -- BUT ONLY ONCE!
The other solution it to copy over: System.Web.Extensions.dll, System.Web.Extensions.Design.dll from C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025 into your bin folder and it should work if your application runs in full trust mode!

Hope it works!


I was able to deploy my ajax app on my server without installing anything, just putting the System.Web.Extensions.dll into the bin folder and referencing it. I am still unable to get the control toolkit to work without installing anything on the server. Any ideas on that?(Sorry, I know it's not the control toolkit forum, but the question fits perfect in this post :) )

Problem instaling and runing AJAX

Hello,

I am trying to install and use AJAX Toolkit. Is there a website with detailed explanation on how to install and use AJAX Toolkit.

Thanks

Hi,

Look at this page for details

http://www.asp.net/ajax/documentation/live/InstallingASPNETAJAX.aspx


Hi Elyubron,

If we want to use Ajax Control Toolkits in our project , we should first install ASP.NET 2.0 Ajax Extension V1.0 then install the Ajax Control Toolkit template(recommended but not necessary).

Here are some useful urls :

http://www.asp.net/learn/ajax-videos/video-75.aspx Get Started with ASP.NET AJAX

http://www.asp.net/learn/ajax-videos/video-76.aspx Get Started with the ASP.NET AJAX Control Toolkit

Also you can find more tutorials here : http://www.asp.net/learn/ajax-videos/

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Walkthrough/OtherNeatStuff.aspx Ajax Control Toolkit

I hope this help.

Best regards,

Jonathan

Problem installing the documentation

When I build the website for the documentation I get the following errors:

Error 37 Unknown server tag 'Samples:ClientVerification'. C:\AJAX Documentation\Samples\LocalizingClientResourcesWalkthrough\cs\Default.aspx 40


Error 36 Could not load file or assembly 'LocalizingScriptResources' or one of its dependencies. The system cannot find the file specified. C:\AJAX Documentation\Samples\LocalizingClientResourcesWalkthrough\cs\Default.aspx 2

I followed the instructions in the readme.txt file and the files are unzipped into the C:\AJAX Documentation folder.

bump

Problem Loading URL into Div

On a website I am working on I am trying to load another page into a div on the the page the user does his work from. What I have works correctly in FireFox, but not in IE. I've rummaged Google for quite a bit and found similar problems, but no set solutions.

Here is the JavaScript I have to load a URL into a Div:
function setResponseHtml(pUrl, pDiv) {
var lHttp = getHTTPObjectHtml();
var lUrl = pUrl;
lUrl = lUrl.replace("+","%2b");
if (isBusy) {
lHttp.onreadystatechange = function () {}
lHttp.abort();
}

lHttp.open("GET", lUrl , true);
lHttp.onreadystatechange = function() { getHttpResponseText(pDiv, lHttp); };

if (window.XMLHttpRequest) { // Mozilla check
if (!isBusy) {
isBusy = true;
lHttp.send(null);
}
} else { // IE Check
isBusy = true;
lHttp.send(null);
}
}

function getHTTPObjectHtml() {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
return http_request;
}

function getHttpResponseText(pDiv, pHttp) {
var lHttp = pHttp;

if (lHttp == null) // just in case!
lHttp = gHttp;

if (lHttp.readyState == 4) {
isBusy = false;

var status = "";
try {
status = lHttp.statusText;
if (lHttp.status == 200) {
var htmlDocument = lHttp.responseText;
document.getElementById(pDiv).innerHTML = htmlDocument;
}
} catch(e) {
status = "Trouble accessing it";
document.getElementById(pDiv).innerHTML = e.message;
}
} else {
if (getAjaxLoadingMessage() != '' && getAjaxLoadingMessage() != null) {
// only display a loading message if it is defined
setVisible(pDiv, true);
document.getElementById(pDiv).innerHTML = getAjaxLoadingMessage();
}
return;
}
}

var gAjaxLoadingMessage = '<b>Loading...</b>';

function setAjaxLoadingMessage(pMessage) {
gAjaxLoadingMessage = pMessage;
}

function getAjaxLoadingMessage() {
return(gAjaxLoadingMessage);
}

This is called from the HTML via: setResponseHtml(urlString, divString);
urlString is a string containing the URL that I wish to load in the div, and divString a string containing the id of the div I wish to load the URL into.

I've tested my code on IE before and it worked properly with a very small file with nothing in except for a couple words. I think the problem may go back to these pages, both the one the users calls the function from and the page to be loaded, contain SharePoint Web Parts. That is the only difference I can think of between the original pages I used to test the code and the pages I am working with now.

An error occurs in IE when trying to load the Div, the error being "[object Error]" and the error message being "Unknown runtime error" if I print e and e.message respectively from the getHttpResponseText function.

This is the section of code where the error occurs:
try {
status = lHttp.statusText;
if (lHttp.status == 200) {
var htmlDocument = lHttp.responseText;
if (gAjaxForeground) {
setVisible(pDiv, true);
}
document.getElementById(pDiv).innerHTML = htmlDocument;
}
} catch(e) {
status = "Trouble accessing it";
document.getElementById(pDiv).innerHTML = e.message;
}

I can't figure out exactly why the error is happening, nor how to correct it. If I change the line "document.getElementById(pDiv).innerHTML = htmlDocument;" to "document.getElementById(pDiv).innerHTML = 'Any text here';" I recieve no errors, so apparently IE doesn't like setting the innerHTML of the page to be loaded to the statusText. Why that is and how to fix it is what I'm hoping to find out.

Just a quick question... why aren't you using IFRAME (or whatnot) for something like this. If you're loading an entire page, you're going to have issues like duplicate HTML and BODY tags.

-Damien


The main reason behind using a DIV is because the content from the page being loaded into the div is dynamic content, and the DIV will resize automatically if needed. One other thing to note is that this DIV tag isn't always visible on the page. When the user mouses over an item on the page a pop-up comes up displaying additional information about the object, as well as allowing the user to edit such information, which is where the AJAX comes in - allowing the user to edit the information without straying away from this page, and the page being loaded into the pop-up is the page that has done the update and is displaying the results. I haven't worked with IFRAMEs that much, but from my understanding all of this is not that possible with them - correct me if I'm wrong. I have thought about about duplicated tags, but in the past and during my testing I've never experienced any problems by having such.


Well, you can't push an HTML string into an IFRAME, but you can load a URL. Think of an IFRAME like your DIV; it's a container. You can perform client-side logic with it (e.g. show/hide) and it's the way to host another page inside a page (like you are doing).

Seehttp://en.wikipedia.org/wiki/IFrame andhttp://msdn2.microsoft.com/en-us/library/ms537627.aspx.

Using the DIV and having duplicate HTML and BODY (not to mention HEAD, etc) will cause issues; plus it's not well formed at all.

Hope this helps you.

-Damien


With a bit of help from someone and a bit more searching online I discovered the cause of my problem. Thought I'd post the actual reason for the problem and my resolution here for anyone that might be having similar issues.

The reason for the Runtime Error were Element Prohibitions within the HTML. The DIV that I was trying to insert into was surrounded by FORM tags and the page I was trying to insert into the DIV had FORM tags within it. To put it simply: You cannot have a FORM inside of a FORM.

See this URL for more information: http://www.w3.org/TR/xhtml1/#prohibitions

IE upholds this, where as Firefox doesn't care and just renders it on screen how it thinks the output should look which is why I was having this problem only in IE.

I couldn't remove the FORM tags because the website I am working on is a SharePoint site that uses Web Parts (which are required to have FORM tags around them - if I removed them I got errors that bluntly said FORM tags were needed). So, to overcome this I modified the function getHttpResponseText() (See my first post to view the code). Rather than dump the repsonseText straight into the innerHTML of the DIV tag I used indexOf to find the start and end of the data that I specifically wanted (in my specific case one table on the page) and used a substring to cut that out from the responseText and dump that into the innerHTML of the DIV, thus eliminating the FORM tags.

No iFrames involved and everything works splendid. :p

On a side not, I went to set my thread to 'Resolved' and it was already set at that. I definitely never did that since I didn't have a resolution until today. If code in the forum did that, I would correct it ASAP. If a person did that, I would smack him/her for not reading the thread properly. Suggesting to use an iFrame as an alternative was never a solution. It was just what I said - an alternative where the original problem still remained. The reason for the error, nor a solution to fix it never existed in this thread until the post I am making now.