Showing posts with label ive. Show all posts
Showing posts with label ive. Show all posts

Wednesday, March 28, 2012

programatically disable dropdown in Ajax updatepanel

I've searched high and low for what seemed would be a simple and frequently used method to access the properties of a drop down contained in a Ajax UpdatePanel without finding anyone who seems to have needed to do this or who has solved it. Maybe Microsoft decided nobody would ever want to do such a weird thing!

I have users with various permission levels. Depending on their level, on page load I need to disable drop downs which are contained within Ajax Updatepanels.

I can expose the properties of the UpdatePanels themselves but they do not support the enable property, only invisible which is no help.

Anyone know how this is done ?

Thanks

Aren't you able to just set the Enabled property of the appropriate DropDownList's?


Dont depends only on UI elements enable/disable state. Also enusre the User level in server side. Can pls post some code i mean in which point you want to disable the dropdown list.

Use CascadingDropDown control in AJAXControlToolKit

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/CascadingDropDown/CascadingDropDown.aspx


Hi,

Are you using the AJAX extension version 1.0.61025.0 ?

I'm using this one. The controls inside UpdatePanel can be accessed directly. For instance:

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void Page_Load(object sender, EventArgs e) { DropDownList1.Enabled = false; }</script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:DropDownList ID="DropDownList1" runat="server"> </asp:DropDownList> </ContentTemplate> </asp:UpdatePanel> </div> </form></body></html>

Wednesday, March 21, 2012

question on ajax & webservices

hello all again

here is what i'm doing,

i've a javascript object, which has key value pairs, and some values are objects themselves.

i'm passing this object to a method in a web service, and i'm able to get the values and also able to see the object (which is a value for some keys),

and also i can read that object (and values) in the callback function in my javascript file.

now my question is - i'm unable to refer to the object's value in .asmx file?

.js object looks like this:

myObj = new customObject(); // customObject is a public class in .cs file with get() and set() methods

myObj['id'] = 1;

myObj['name'] = 'test';

addressObj = new secondCustomObject(); // secondCustomObject is a public class in .cs file with get() and set() methods

addressObj['streeName'] = 'test Street Name';

addressObj['City'] = 'test City';

myObj['address'] = addressObj;

webservice.methodName(myObj, callback);

can anyone guide me how to read the addressObj's values in .asmx file?

Thank you

Sanjay

Hi

Would you please post a demo of your issue?

To troubleshoot this issue, we really need the source code of your webservice to reproduce the problem, so that we can investigate the issue in house. It is not necessary that you send out the complete source of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business logic from it.

Thank you.


Hi

Basically we only need to modify the proxy class that is generated when you add a web reference. I googled and found a nice article about this.

http://ryanfarley.com/blog/archive/2004/05/26/737.aspx


Let me know if you need more info.

Hope this helps.

Thanks!

NOTE:This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


Hi

Demo:

Page:

<%@. Page Language="C#" %>

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

<script runat="server">

</script>

<script type="text/javascript">
function HelloWorld()
{
myObj = new person("Andrew","Yin");
myObj["firstName"] = "Jin Yu";
myObj["lastName"] = "Yin";
TestWebService.HelloWorld(myObj,SucceededCallback);
}

function person(fName, lName)
{
this.firstName = fName;
this.lastName = lName;
}
function SucceededCallback(result, eventArgs)
{
// Page element to display feedback.
var RsltElem = document.getElementById("ResultId");
RsltElem.value = result;
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager runat="server" ID="scriptManagerId">
<Services>
<asp:ServiceReference Path="TestWebService.asmx" />
</Services>

</asp:ScriptManager>
<input id="ResultId" type="text" />
<input id="Button1" type="button" value="button" onclick="javascript: HelloWorld();" /></div>
</form>
</body>
</html>

WebService And Class:

using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;


/// <summary>
/// Summary description for TestWebService
/// </summary>
[ScriptService]
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class TestWebService : System.Web.Services.WebService {

public TestWebService () {

//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]
public string HelloWorld(person p) {
return "Hello World, " + p.firstName + " " + p.lastName;
}

}

public class person
{
public string firstName = "";
public string lastName = "";
}

Hope this helps.

Thanks


Thank you Yin-Yu for your reply,

I figured that part out, what i'm doing is pass the javascript object with key value pairs and some values are objects [with key value pairs] themselves.

in .asmx file i created custom datatypes for 1. key value pairs and 2. objects. this way i can see my elements [belongs to child objects] in my .asmx file

Thank you

Sanjay

Question regarding AJAX, Blinq etc

Ive noticed lately Microsoft are introducing AJAX, Atlas, WPF,Blinq and many more new technologies.

My question is based on myself being a relatively newcomer to ASP .Net 2.0 and dont know everything but know some as ive developed more with applications rather than websites. So am i wasting my time in learning ASP .Net 2.0 as these new technologies means ASP .Net 2.0 will become "redundant" or "not a standard"? should i concentrate learning these new technologies or continue learning ASP .Net 2.0 as these new technologies will fall in place at some stage?

Thanks

EssCee

ASP.Net 2.0 is the foundation for these technologies, so in my opinion learning asp.net first is fundamental to understanding these other "enhancement" technologies. For example, ASP.NET AJAX (formerly Atlas) is simply an extension to asp.net...not a seperate technology unto itself. Blinq is basically dynamically creating asp.net pages from a data source...so again, built on top of asp.net.

WPF is slightly different I believe in that it is centered around building windows client applications...specifically building nice GUI's to windows client applications. It is more an extension of .Net as a whole than just ASP.NET...I think anyway (someone feel free to correct me).

Matt

Question: How can I get embedded images to work in my extender?

I've followed the Slider, and the ValidatorCallout .. but my images will just not work. Anything more than just the assembly line, and what is in the javascript to get this to work?

I get the "my images will just not work" part. As for the rest, I'm not sure. But what I'd like to know is how you makeHandleImageUrl="../T1818.jpgwork. Is there something more required to make an 18x18 image replace the default slider handle? Maybe we're asking the same question?


There are a couple steps to embedding the image with your extender.

First, add the image to your assembly as an Embedded Resource, just like the behavior js file associate with the extender.