ラベル web の投稿を表示しています。 すべての投稿を表示
ラベル web の投稿を表示しています。 すべての投稿を表示

2012年3月28日水曜日

requirePermission="false" in the web.config return warning.

I have unstalled AJAX rc 1 and I get the following warning(4 times), from my web project web.config, after compilation:

"The 'requirePermission' attribute is not declared"

How can I get rid of this warning ?

It comes from this section:

<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>

Hi leeorc

pleas review link below

http://forums.asp.net/thread/1204349.aspx

hope it helps you


Ok I took the following advice:

You can workaround it by opening "c:\Program Files\Microsoft Visual Studio 8\XML\Schemas\dotnetconfig.xsd" and inserting the following at line 40:

"<xs:attribute name="requirePermission" type="boolean_type" use="optional" />"

-------------------------------

Despite the fact that one person didnt recommend it, the workaroundhelpedme with non harmful ireversable issues.

Thanks

Leeor


I found that in the string "<xs:attribute name="requirePermission" type="boolean_type" use="optional" />", the type should be Type, I mean the t should be upper cased.

Liang

ResolveUrl equivalent from web service

Hi,I need to resolve a relative URL (eg "~/path/to/file") from within a web service. The only way I know how is using Control.ResolveUrl (or ResolveClientUrl) but obviously neither of these are available from outwith a control context. I've had a look with Reflector at what goes on in those methods and it all uses internal classes so I don't know how I can emulate it.Any ideas? I'm sure theres a method for this somewhere I just need it pointed out!CheersRory

try:

HttpContext.Current.Server.MapPath("~") + "/App_Data/TestFile.jpg", ImageFormat.Jpeg);


Thanks for the reply but I don't see how thats going to help me.

Maybe I wasn't clear enough but I need a Url I can return to the browser. ie From "~/path/to/file" I want to get "/MyApp/path/to/file"


sorry, not much of client side guy myself. I thought you were trying to resolve ~ in a web service to a real path

2012年3月26日月曜日

Response.Redirect in Asp.net AJAX

Hi All,

I Developed a project in as.net with Asp.net Ajax... i used Response.Redirect several time in my web project with and without script manager... and its worked fine...
but some tells me...this is not recommended to use Response.Redirect in asp.net AJAX....and when i will deploy on Production server... there may be chance of some error.............

So please give your opinon....
Thanks
SajjadPerhaps you are confusing this with Server.Transfer. There should be no issues with Response.Redirect.
R u 100% sure...
and what issue with Server.Transfer....

REsponse.Redirec will not cause any issues if you invoke it from CodeBehind pages.

I have worked with one developer who instantiated the Page object, and tried to use the page object.REsponse.REdirect() and that failed - as it should.


result from web service is what type/object?...

Hi ALL,

At first i was using older version of the AJAX toolkit and the Sys.Net.WebServiceProxy Class was not set. I was getting an error trying to run the posted samples...

Next, i got the latest RC version and updated my toolkit. So far, everything seems to be working great, except the part when the web service result comes back (in the OnSuccess method).

Following the samples, instead of the actual string result i see XML Object. I mean from a simple web method "HellowWorld() as string", instead of a string i see XML Object.

I tried alerting the result.xml, assuming it is of XMLDom object and that is what it is?... Should this be JSON parsed value vs actual XMLDom.

I mean if the webservice returned a stirng, result should be a string, if the web service returned an object with properties A and B, i should be able to access it like this: alert(result.A), and e.t.

Any thoughts will be appreciated!

Ivan

I am sure you all have seen and tried this:

http://ajax.asp.net/docs/Samples/Sys.Net.WebServiceProxy/vb/WebServiceProxy.aspx

In my case, instead of actual server time string for example for example i would see "[object]"...

This object returned is the XMLDom corresponding to the result which i could certainly use and go further with my development, but i am afraid that this may not be the right way. According to the documentation, the result should be the actual object returned from the web service, in this case a string...


You didn't happen to put a ScriptMethod attribute on your web service method to change the ResponseFormat from the default of JSON to XML, did you?

return a html table with ajax C#

hi

I am writing a website using C#, web services and ajax. I have my ajax web service call returning either an array or a DataTable object. Does anyone have any example of writing either one of these returned values to a html table using javascript?

thanks

C

It might help http://dotnetslackers.com/articles/ajax/ASPNETAjaxGridAndPager.aspx

2012年3月24日土曜日

Returning a dataset from a web service

Say I have a page that calls a web service from a client function to get some data to bind a gridView like this:

-------------------

<scripttype="text/javascript"language="JavaScript">

function GetDataSet(){

var ds = SimpleService.ActiveProcess();

}

</script >

-------------------

And the web service looks something like this:

-------------------

[WebMethod]

public datasetActiveProcess(){

string connectionString ="Connstring stuff here";

DataSet ds = csql.GetActiveProcess(connectionString);

return ds;

}

-------------------

Of course, because I'm posting this problem, this isn't the correct way to implement this kind of solution...

Question is: Is there a better way? Or how do I manage to handle and display what's being returned from this web service in the web page?

thanks.

doug

This issue is associated with an Atlas Web Service call.

Here is a crude solution that I still need to refine:

------------------------

1. JavasScript call to webservice:

------------------------

function fnSetTimeout( ){

//this is the call to the web service.

var ds = SimpleService.ActiveProcess(OnComplete, OnTimeout);

}

------------------------

2. Webservice method

------------------------

[WebMethod]

publicstring ActiveProcess(){

string connectionString ="Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Initial Catalog=simple2;Data Source=local

string xmlReader = csql.GetActiveProcess(connectionString);

return xmlReader;

}

------------------------

3 Webservice method

------------------------

publicstring GetActiveProcess(string connString)

{

string strSQL ="Select id, threadid, conversationId from ActiveProcess";

SqlConnection conn =newSqlConnection(connString);

SqlDataAdapter da =newSqlDataAdapter(strSQL, conn);

DataSet ds =newDataSet();

try

{

conn.Open();

da.Fill(ds);

XmlDataDocument xmlDataDocument =newXmlDataDocument(ds);

return xmlDataDocument.OuterXml.ToString();

}

catch (SqlException ex)

{

returnnull;

}

}

------------------------

3 Load the XML into parser

------------------------

/*==============================================================================

function: OnComplete

paramaters: result

Purpose: Gets the results from the ATLAS call and parses into an XML document

Date: 12/21/2005

==============================================================================*/

function OnComplete(result)

{

//Load XML

var XMLDoc =new ActiveXObject("Microsoft.XMLDOM");

try

{

XMLDoc.loadXML(result);

}

catch(err)

{

alert(err.description);

}

//Load XSL

var XSLDoc =new ActiveXObject("Microsoft.XMLDOM");

try

{

XSLDoc.async =false;

XSLDoc.load("ActiveRecords.xsl");

}

catch(err)

{

alert(err.description);

}

//Write the results of the transformation out to the div.

document.all.divTable.innerHTML = XMLDoc.transformNode(XSLDoc);

}

Here's the XSL if you're interested:

<?xmlversion="1.0"encoding="utf-8"?>

<xsl:stylesheetversion="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:templatematch="/">

<html>

<head>

<title>Active</title>

<style>

copy { font-family: Arial, Verdana;}

h1 { font-family: Arial, Verdana; font-size: 14pt;}

p { font-family: Arial, Verdana; font-size: 10pt;}

</style>

</head>

<body>

<p><fontface="verdana">Active</font></p>

<tableborder="1">

<tr>

<thclass="copy">ID</th>

<thclass="copy">Thread Id</th>

<thclass="copy">Configuration ID</th>

</tr>

<xsl:for-eachselect ="NewDataSet/Table">

<tr>

<td>

<xsl:value-ofselect="id"/>

</td>

<td>

<xsl:value-ofselect="threadid"/>

</td>

<td>

<xsl:value-ofselect="conversationId"/>

</td>

</tr>

</xsl:for-each>

</table>

</body>

</html>

</xsl:template>

</xsl:stylesheet>

thanks...

Returning dynamic JSON from ASP.Net

I have an ASP.Net web service that I want to return a JSON response. The method that I am working on in particular calls another web service that already gives me a JSON response. All I want to do is return that to the caller of my webservice (it will be a .htm/.js caller).

I have already found a way to make it work, but it doesn't seem optimal. If I define some local objects in my web service that look like the JSON response I get from the third party web service, I can deserialize the response into my local objects, and return the object from my web service. If I call the service from the browser with the JSON request type, I get back the correct JSON response. But in this case I have taken a JSON string, converted it to an object and back again, which seems like too much work. Plus, I'll have an extra layer of objects that have to be kept in sync with the third party response.

If I just return the JSON that I get from the third party webservice (as a string), in the browser I get a string that can't be EVAL'd into a js object. It has quotes around the whole thing and all the internal quotes are escaped, etc. It is basically just a string, not JSON.

So, the question is, how can I define a web service method that returns any JSON that can be called from a simple htm/js client and get it to return valid (ready to eval) JSON? What return type should I be using?

Backslider

ASP.NET AJAX web services only support returning objects. These objects will be serialized by the AJAX services layer. There is no returntype to hold raw JSON , and skip this serialization.

However if you return the JSON as a string, you should be able to eval the response once to get the string response from thirdparty webservice(If you use a proxy generated by ASP.NET AJAX it would returned an already eval'ed response). Once you get the string, you should be able to eval it again to get the actual js object.


Have you tried letting your server convert it into a .Net object?

Returning results from a page method call

In my ASP.NET AJAX web site, I am attempting to use Page Methods to return data from the web server. I would like to be able to return the value from a page method like so:

function GetValue()
{
return PageMethods.GetValueFromServer();
}

function ManipulateValue()
{
var myValue = GetValue();

// Do something with myValue
}

Unfortunately, calling a page method requires the use of a callback function. I really need to retrieve the value without having to store it in a global variable in the callback function; is there any way to do this?

function GetValue(){ return PageMethods.GetValueFromServer( function(result){// The result that is returned from server //Now do what ever you would like to do.} );}
Maybe you can try something like this

KaziManzurRashid:

function GetValue()
{
return PageMethods.GetValueFromServer(

function(result)
{
return result;
}

);
}

Maybe you can try something like this


I tried your code, returning the result in the nested callback function (see above), but when I returned to the code that calls GetValue() the value that ends up getting returned is undefined. :-(


Yes that becasue the ajax call is async. it does not wait for the ajax call to complete, why do not you call the GetValue in the Callback?


KaziManzurRashid:

Yes that becasue the ajax call is async. it does not wait for the ajax call to complete,why do not you call the GetValue in the Callback?



Okay, I'm somewhat confused. I call GetValue(), which calls an asynchronous server method and is passed an in-line Javascript callback function. Are you saying that I should, in the callback function, call GetValue() again? If so, won't that just cause an infinite loop?


Sorry let me rephrase. You do not need to call the GetValue again in the callback although doing it will not make it recursive. You can call your desired outer ManipulateValue function in the callback but in that case the ManipulateValue will not again call the GetValue.


KaziManzurRashid:

Sorry let me rephrase. You do not need to call the GetValue again in the callback although doing it will not make it recursive. You can call your desired outer ManipulateValue function in the callback but in that case the ManipulateValue will not again call the GetValue.

Okay, I tried that but still no luck. Here is the code I am using; perhaps you can shed some insight on to what I'm doing wrong? It looks like this is, in fact, causing an infinite loop.

Javascript code:

function PrintDateTime()
{
var dateTimeFromServer = RetrieveDateTime();
$get("myLabel").innerHTML = dateTimeFromServer;
}

function RetrieveDateTime();
{
return GetAjaxValue();
}

function GetAjaxValue()
{
return PageMethods.GetCurrentDateTime(
function (result)
{
return RetrieveDateTime();
}
);
}

C# code:

[WebMethod]
public static string GetCurrentDateTime()
{
return DateTime.Now.ToString();
}


You can do it in the following way:

function GetAjaxValue(){ return PageMethods.GetCurrentDateTime( function (result) { $get("myLabel").innerHTML = result; } );} function showCurrentDateTime(){GetAjaxValue();}

Just call the showCurrentDateTime in your code when you want to show it.


KaziManzurRashid:

You can do it in the following way:

function GetAjaxValue()
{
return PageMethods.GetCurrentDateTime(
function (result)
{
$get("myLabel").innerHTML = result;
}
);
}
function showCurrentDateTime()
{
GetAjaxValue();
}

Just call the showCurrentDateTime in your code when you want to show it.

Thanks for the time you've spent addressing my questions, Kazi. Unfortunately, in my code I really need to return the value in the RetrieveDateTime() function. The code in PrintDateTime() is just used for illustration; I need to do more than just put it in a label. To clarify, here's exactly what I want to do:

var myValue = RetrieveDateTime();

The value is not being displayed on screen but is being used by logic within a JavaScript function. I really just want to be able to call a JavaScipt function and return a value that I can use in the rest of the code.


Hi, Well you have to undertand the nature, it is always. and thats why the best place to assume the value is availabe is the Callback. If you can describe more of your scenerio then I can help.


Hi,

Thank you for your post!

It seems that you have misunderstanding on AJAX and callback.

The result cann't be obtained like this:

var myValue = GetValue();

It must be obtained like this:

function SetSessionValue(key, value)
{
PageMethods.SetSessionValue(key, value,
OnSucceeded, OnFailed);
}

// Callback function invoked on successful
// completion of the page method.
function OnSucceeded(result, userContext, methodName)
{
if (methodName == "GetSessionValue")
{
displayElement.innerHTML = "Current session state value: " +
result;
}
}

// Callback function invoked on failure
// of the page method.
function OnFailed(error, userContext, methodName)
{
if(error !== null)
{
displayElement.innerHTML = "An error occurred: " +
error.get_message();
}
}

For more information about callback and webmethod, seehttp://www.asp.net/ajax/documentation/live/tutorials/ExposingWebServicesToAJAXTutorial.aspx

If you have further questions,let me know.

Best Regards,

Returning selected value from ModalPopup in a custom web control

I'm a little lost on how to do this conceptually -- can someone perhaps shed a little light on how this might be done?

    Custom web control consists of UpdatePanel with other UI controls and a ModalPopupExtender. The purpose is to be a reusable search popup, and I've got the search UI functionality working like a champ.

    Page with an UpdatePanel containing some container (textbox, listbox, label, etc), a linkbutton, and my custom control from #1.

What I would like to do is have the linkbutton call some script (be it client- or server-side, not sure what's the most appropriate yet) that does the following steps:

    Show the custom popup

    Allow the user to perform the search and select one of the results, which would close the popup

    Snag the selected value from my popup, then work with that value to update the container (i.e. if it's a listbox, then do some script to insert an appropriate item)

How can I pull this one off, so the search popup is an isolated, reusable control? I've got different instances where I need the selected value to change a Label, update a TextBox, or even be inserted in a ListBox. I've got plenty of public properties on the custom control already that determines the parameters for the search itself; is there a perhaps way to override the Show() method so that it would return the value of the selection after it closes? But since Show() wouldn't really block, I'm lost on how to do it.

Thanks a lot,
Jon

Am I screwed on this one? The best I've been able to get are two separate custom controls with a LOT of duplicated code ...

Control contents: Listbox, linkbutton to show popup, all the popup code

Then repeat with a new control replacing the Listbox with a Label etc ...

I hate having this much duplicated code; anytime I need to change the popup code I'll have to duplicate it in each of my custom controls. There has to be a better way to do this?!?


I am not sure if i understand you question 100% from what ive read but if you want to get a value return from the mod popup is should not be to hard.

Lets say i have a mod popup that has a textbox, a search button, a listbox of results and a submit button. What you could do is once you have run the search which you said is working great, display the results in the listbox in the popup. then when the user clicks the submit button an event is fired that checks to see if they selected one of the items in the list box, if not then it will tell them to do so. Then if you want to use that selected value to populate a listbox on the main for (say for example you searched in the popup for a street name and then selected the right street name from the listbox and clicked submit and you want the main form listbox to display all people on that street) then all you need to do is have the event for the submit button Click call a function you write that runs the query to get all people on that street and print their info the the list box.

It should not be hard to get the results from the popup, but im not sure i understand what you are asking so this could be no help at all :P


Well! There's a little different between the concept of Modal Popup in Windows and Web forms. The latter is just hiding all the controls in the Popup and show when needed but you should able to access the properties of those controls within the scope of the page.

Now, assuming that you want to create a ASP.NET reusable custom server control that "know-how" to popup a modal to collect data from the end-user. The basic class design can be used so you just have to declare a public property so that it can return the selected value. Another alternative is you can use a Session key to store the value so that the class container can retrieve after using your class. This key can be set as a property of your class prior to the container is using it.

I hope it help since your question left a lot of detail out hence it's not very clear.


My apologies for not being clear enough -- I think I wrote the initial post after too much coffee and a bit too much frustration. :(

The overall project is an admin web UI for AD objects, so popup searches are going to be very common. Some pages will have multiple popup searches, so it is my desire to completely wrap all of that functionality into a single reusable custom server control. The results of the search could be used to update different types of UI elements on the parent page; my struggle is with conceptually figuring out where the pieces go to make this work in more than one situation.

My custom control now is an UpdatePanel with all the search UI and tidbits inside, and a ModalPopupExtender. There are many public properties on my control, mostly to define how the search itself is going to work. TargetControlID for the extender is also exposed as a public property, so that I can wire the popup to any UI element on the parent page that I want. The control also has a hidden element in it; this hidden element eventually contains the selection the user chose from the search results and is exposed via a public "SelectedResult" property.

Everything up to this point is working 100%. I'm stuck, however, on implementing the hooks for getting the value back to the parent page. Once someone clicks the TargetControl and performs the search and selects a result (which then hides the popup through server script in the control itself), the result is stored in the hidden element and the user is back at the parent page. But how do I work with that SelectedResult then? I should be able to, once the popup is hidden, take that value and stick it somewhere on the parent page -- but apparently I'm missing something obvious, because I'm completely lost.

Do I handle it via a custom click event for the wired target (instead of just using TargetControlID)? Does OnOKScript fit in here somewhere? Since the activity to take place after a selection is made will be different depending on the situation, it needs to happen outside of my custom control. Are there additional extender props that I need to expose through a public property on my custom control?

I hope this helps -- I'm not seeking exact code samples, I'm more looking for help on getting my brain wrapped around the "how" of the solution ... the exact code I should be able to figure out after that, I think. If some of my code for certain parts would help, I'll be happy to post them -- just let me know. Thanks again!


Alright so im still not sure if this is anything helpful, but i have a small example here i wrote of what i would do to put the result from my modal popup into my main page and from there i could do what ever i want with it. I tried to comment the best i could to make it super easy to read

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 AjaxControlToolkit;public partialclass administration_OIS_Default : System.Web.UI.Page{ ModalPopupExtender modPop =new ModalPopupExtender();//The main modal popupprotected void Page_Load(object sender, EventArgs e) { HiddenField results =new HiddenField();//Results from mod popup HiddenField hidden =new HiddenField();//Mod popup targetID UpdatePanel update =new UpdatePanel();//UpdatePanel to hold controls TextBox tempText =new TextBox();//Textbox for mod popup Button btnVisible =new Button();//Button to show mod popup Button btnSubmit =new Button();//Submit button in mod popup Panel container =new Panel();//Panel to hold controls for mod popup //Assign IDs to variables that need to be refrenced later container.ID ="Container1"; results.ID ="Result1"; hidden.ID ="Hidden1"; btnVisible.Text ="Click to show modPop"; btnVisible.ID ="visibleButton"; btnVisible.Click +=new EventHandler(this.btnVisible_Click);//Tell the button what do do when click update.ContentTemplateContainer.Controls.Add(btnVisible);//Add the button to main update panel update.UpdateMode = UpdatePanelUpdateMode.Conditional;//We only want the panel to update sometimes update.ChildrenAsTriggers =true;//IE. when child controls trigger it update.ContentTemplateContainer.Controls.Add(hidden);//Add "hidden" to the update panel tempText.ID ="textBoxTest";//Add a simple textbox to the control container.Controls.Add(tempText);//container to be placed in our modal popup btnSubmit.Text ="btnSubmit"; btnSubmit.ID ="btnSubmit1"; btnSubmit.Click +=new EventHandler(this.btnSubmit_Click);//tell submit what to do when clicked container.Controls.Add(btnSubmit);//and add it to our control container modPop.TargetControlID = hidden.ID;//We would rather use modpopup.Show() so we make this a hidden field modPop.PopupControlID = container.ID;//Define the object to be shown inside of mod popup modPop.DropShadow =true;//Why not a little style :P modPop.X = 500; modPop.Y = 250; update.ContentTemplateContainer.Controls.Add(modPop);//Add the modal popup to our update panel update.ContentTemplateContainer.Controls.Add(results);//Add our results holder to the update panel update.ContentTemplateContainer.Controls.Add(container);//Also add the modal popup contents form1.Controls.Add(update);//Add our updatepanel to the main form }/// <summary> /// Function will force the modalPopup extender function .Show to fire /// </summary>private void btnVisible_Click(object sender, EventArgs e) { modPop.Show(); }/// <summary> /// Function takes the users input from the modal popup and saves it to a hidden field /// located in the updatepanel so that it will be save for further use /// </summary>private void btnSubmit_Click(object sender, EventArgs e) { ((HiddenField)form1.FindControl("Result1")).Value = ((TextBox)((Button)sender).Parent.Controls[0]).Text; }/// <summary> /// Function will display the saved value from the modal popup to prove that it works /// </summary>private void showText() { txtOutput.Text = ((HiddenField)form1.FindControl("Result1")).Value; }/// <summary> /// Occurs when button1 is clicked, showing the save results from modal popup /// </summary>protected void Button1_Click(object sender, EventArgs e) { showText(); }}
 So basically the user will click a button here to show the modal popup. enter text and click submit in the modal popup, and then they are brought back to the main form where if they click on Button1,
the value that they entered into the modal popup will be displayed. I got lazy at the end and didnt add txtOutput or Button1 programmatically so if you want to run this code on your own i think those are
the only 2 things you will have to manuall add to the form
Enjoy

You know what, I think I've got it ... maybe I just needed to "air it out" and let my mind wander for a bit. Seems like it would be simple after all, let me know if I'm off base:

I could just have the custom control expose another public property, and the parent page sets that property to a hidden control on the PARENT PAGE. Then the custom server control sets that hidden control's value before calling hide(). The hidden control on the parent page would have an onChanged() event that could do whatever UI update activity is necessary. That would keep all of the code separate from the custom control, allowing it to work in any situation I needed.

I'm going to try that right now ... if it is indeed this simple, my apologies for going around in circles on this one Embarrassed


Sounds like your on the right track now, well at least the track that I felt is what would help you get to where you want to go. and yeah, sometimes its best to take your mind of things then come back with a different perspective, or go onto forums like this and let someone else share their point of view, it saves a lot of frusterationSmile


It actually turns out to be even simpler -- I just need my custom control to raise a public event when the user selects a search result, and passes the selection as part of the args. The consuming page just watches for that event and does whatever UI magic is necessary as a result. No hidden fields or other stuff in the middle.

Amazing how much clearer things get after talking it out. Thank you everyone for your help and patience -- I'll try to make this control available publicly shortly and post a link in this thread; your help has been invaluable!


invaluable, wow i feel specialBig Smile


Can you please give some example on how the modal popuo raises a public event and how the parent page watches for the event? Thanks.

jmbutler:

It actually turns out to be even simpler -- I just need my custom control to raise a public event when the user selects a search result, and passes the selection as part of the args. The consuming page just watches for that event and does whatever UI magic is necessary as a result. No hidden fields or other stuff in the middle.

Amazing how much clearer things get after talking it out. Thank you everyone for your help and patience -- I'll try to make this control available publicly shortly and post a link in this thread; your help has been invaluable!


Sure thing!

My ModalPopup is completely contained in a custom web control, so in that control's code I've first defined the custom event that I will raise, including a custom derived EventArgs class that will include the information about which search result the user selected:

public delegate void ResultSelectedEventHandler(object sender, SelectedEventArgs e);public event ResultSelectedEventHandler ResultSelected;public class SelectedEventArgs : EventArgs {public string Selection;public SelectedEventArgs(string selection) {this.Selection = selection; } }protected virtual void OnResultSelected(SelectedEventArgs e) {if (ResultSelected !=null) ResultSelected(this, e); }

Then in the click code for my selection button, I raise this event before hiding the popup ("RadioSelect" is a radio button from my search panel's GridView; it's value is a two-dimensional string array separated by '|'):

protected void lnkAddSelected_Click(object sender, EventArgs e) {// raise an event to notify the consuming page that a selection was made OnResultSelected(new SelectedEventArgs(Request.Form["RadioSelect"]));// we're done; close the popup ModalPopupExtender1.Hide(); }

Now, back on the consuming parent page, I subscribe to this event in the markup of my custom control (note I've exposed TargetControlID publicly as well so I can wire my custom control to anything I want):

<uc2:PopupADSearch ID="PrimaryOwner" runat="server" TargetControlID="lnkChangePrimaryOwner" OnResultSelected="PrimaryOwner_Selected" />

Finally, in the code for my parent page, I define the PrimaryOwner_Selected method:

protected void PrimaryOwner_Selected(object sender, PopupADSearch.SelectedEventArgs e) {string[] selection = e.Selection.Split('|'); hidPrimaryOwner.Value = selection[0]; lblPrimaryOwner.Text = selection[1]; }

It's also important to note that the custom control, hidPrimaryOwner (a hidden control), and lblPrimaryOwner (a typical label server control) are all within an UpdatePanel -- otherwise all this jazz wouldn't work without a full-page postback. Hope you find this useful!


Hi,

From this post, I felt that you guys h've worked in Modal popup extender. I am posting my question expecting help if anyone knows.

I display Modal Popup( which shows the grid rows and button controls in panel) on clicking imagebutton. I want to align the the button in panel to center ans currently its left aligned and looks awkward. Can anyone tell me how do we align the button control in Model Popup's panel..

Here is the existing code.

Code forbtnSubmit is underlined in Italic in below code for easy identification.

///<summary>

/// Event Handler for Grid selection

///</summary>

///<param name="sender"></param>

///<param name="e"></param>

protectedvoid apprvlsGrid_SelectedIndexChanged(object sender,EventArgs e)

{

if (apprvlsGrid.SelectedIndex >= 0)

{

vwbenftsImgBtn.Visible =true;

string gridAprveSwID;

// Validations on Approve and reject buttons using javascript

if(apprvlsGrid.SelectedIndex <= 7)

gridAprveSwID ="ctl00_ContentPlaceHolder1_apprvlsGrid_ctl0"

+ (apprvlsGrid.SelectedIndex + 2) +"_approveSwHdn";

else

gridAprveSwID ="ctl00_ContentPlaceHolder1_apprvlsGrid_ctl"

+ (apprvlsGrid.SelectedIndex + 2) +"_approveSwHdn";

apprvBtn.Attributes.Add("OnClick","return fnaprvValidate('" + gridAprveSwID +"')");

rejectBtn.Attributes.Add("OnClick","return fnrejValidate('" + gridAprveSwID +"')");

// Controls declared dynamically for Modal Popup using Ajax

Button vwbenftsBtn =newButton();

Button btnSubmit =newButton();

Panel container =newPanel();

container.Width = 400;

container.Height = 350;

container.BorderWidth = 1;

container.BackColor =Color.WhiteSmoke;

GridView benfGrd =newGridView();

//Assign IDs to variables that need to be refrenced later

container.ID ="Container1";

benfGrd.ID ="benfGrd";

benfGrd.AutoGenerateColumns =false;

benfGrd.Width = 400;

benfGrd.Height = 300;

Literal newline =newLiteral();

Literal spaces =newLiteral();

Approvals apprvls;

Approval aprvalVwBenfts =newApproval();

if (Session["aprvlsList"] !=null)

{

apprvls = (Approvals)Session["aprvlsList"];

int iApprvlsCount = apprvls.Count;

GridViewRow aprvlsSelectRw = apprvlsGrid.SelectedRow;

aprvalVwBenfts.BinId =Convert.ToInt64(aprvlsSelectRw.Cells[13].Text);

aprvalVwBenfts.CardId =Convert.ToInt64(aprvlsSelectRw.Cells[14].Text);aprvalVwBenfts.SetId =Convert.ToInt64(aprvlsSelectRw.Cells[15].Text);

aprvalVwBenfts.TableCd = aprvlsSelectRw.Cells[17].Text;

aprvalVwBenfts.EffDate =Convert.ToDateTime(aprvlsSelectRw.Cells[7].Text);

aprvalVwBenfts.SetDesc = aprvlsSelectRw.Cells[6].Text;

if (aprvalVwBenfts.TableCd =="B")

aprvalVwBenfts.TableID = aprvalVwBenfts.BinId;

else

aprvalVwBenfts.TableID = aprvalVwBenfts.CardId;

for (int iRow = 0; iRow < iApprvlsCount; iRow++)

{

if (aprvalVwBenfts.TableID == ((Approval)apprvls[iRow]).TableID

&& aprvalVwBenfts.SetId == ((Approval)apprvls[iRow]).SetId

&& aprvalVwBenfts.TableCd == ((Approval)apprvls[iRow]).TableCd&& aprvalVwBenfts.EffDate == ((Approval)apprvls[iRow]).EffDate)

{

int isetBenftCOunt;

isetBenftCOunt = ((Approval)apprvls[iRow]).getSetBenefitCount();

SetBenefit[] setSetBefts = (SetBenefit[])((Approval)apprvls[iRow]).getSetBenefits();

//Loads the Modal Pop up controls

// Dynamically create field columns to display the desired

// fields from the data source. Create a TemplateField object

// to display an author's first and last name.

TemplateField benfGridCol =newTemplateField();

// Create the dynamic templates and assign them to

// the appropriate template property.

benfGridCol.ItemTemplate =newGridViewTemplate(DataControlRowType.DataRow,"");

benfGridCol.HeaderTemplate =newGridViewTemplate(DataControlRowType.Header, aprvalVwBenfts.SetDesc);

// Add the field column to the Columns collection of the

// GridView control.

benfGrd.Columns.Add(benfGridCol);

benfGrd.DataSource = createGridData(setSetBefts, isetBenftCOunt);

benfGrd.DataBind();

vwbenftsImgBtn.ID ="vwbenftsImageBtn";

vwbenftsImgBtn.ToolTip ="View Benefits for Selected Set";

//vwbenftsImgBtn.Click += new ImageClickEventHandler(this.vwbenftsImgBtn_Click);

container.Controls.Add(benfGrd);

btnSubmit.CssClass ="btn";

btnSubmit.Text ="Close";

btnSubmit.ID ="btnSubmit1";

newline.ID ="newline";

newline.Text ="<br/> ";

//spaces.ID = "spaces";

//spaces.Text = "aaaaaaaaaaaaaaaaa";

//spaces.Visible = false;

//subBtnTble.Style = "center";

//subBtnTble.ID = "subBtnTble";

//subBtnTble.Controls.Add(btnSubmit);

container.Controls.Add(newline);

//container.Controls.Add(spaces);

container.Controls.Add(btnSubmit);

// Specify the Image button as Modal Popup target

modPop.TargetControlID = vwbenftsImgBtn.ID;

//Define the object to be shown inside of mod popup

modPop.PopupControlID = container.ID;

modPop.DropShadow =true;

modPop.X = 250;

modPop.Y = 100;

modPop.OkControlID = btnSubmit.ID;

// Add all the controls to Page's form

formApvl.Controls.Add(vwbenftsImgBtn);

formApvl.Controls.Add(modPop);

formApvl.Controls.Add(container);

}

}

}

}

}

Thanks

Shilpa


Actually, I don't think this has anything to do with this thread -- your question is more geared towards HTML / CSS. You can center any HTML entity using appropriate CSS. If you need more specific answers, I would recommend starting a new thread entirely in one of the other forums (while you are referring to an AJAX extender, your question really has nothing to do with AJAX.)

Returning web service result from calling function in javascript (Atlas)

When using Atlas is there a way that I can call a web service method and have the result returned from the calling function. I understand that Atlas works asynchronously and therefore uses callback functions but I need the calling function to return the result somehow.

I tried something similar to the following but it didn't work. It seems to be that the global variable only gets updated once the calling function completes.

var getResult;
function LMSGetValue(param) {
// Note that the LMSAPI is setup with a ScriptManager
LMSAPI.LMSGetValue(param,LMSGetValueComplete);
pause(1000);// helper function that pauses by # millisecs
return getResult;
}
function LMSGetValueComplete(param) {
getResult = param;
}

The reason that I have to return the result from the calling function is that the javascript that calls the function (which is located in a iframe) follows a strict specification called SCORM which is used for building sharable elearning content and learning management systems (LMS). The learning content in the iframe calls the LMSGetValue function to get the data from the LMS and expects a return value.

Any help or suggestions on how I might be able make this scenario work would be grately appreciated as I really am quite stuck.

Unfortunately there is no current support for synchronous webservice calls, you cannot return a value from your method directly, the results are only available thru your callback.

rjs Popcalendar in UpdatePanel

I've got a web page that allows users to enter X number of people for an application. I have an asp:Table contained in an UpdatePanel. The trigger for the UpdatePanel is a dropdown list that is used to select the number of people the user wishes to enter (1-14). On the initial page load only the 1st row in the asp:Table is visible and when the user selects how many people to enter I use an AJAX call to hide/show the appropriate asp:Table rows. Each row in the asp:Table contains a rjs:Popcalendar to select the date of birth. All the Popcalendar controls work fine if all the rows are set to Visible="true" on the initial page load. However, any row that has Visible="false" on the initial page load and is set to visible via the AJAX call gives the following error when the Popcalendar is clicked: Error: 'calResidentDOBX' is undefined

It appears that the page is only aware of the Popcalendar controls in the rows that are initially visible when the page loads. How can I make the page aware of the Popcalendar controls for the rows being set to Visible="true" in the AJAX call?

Thanks

Hi,

It's a javascript object undefined error,I think the simplest way to fix it is:

checking if there is a html control with it's ID set to "calResidentDOBX",

if there is no such control,the ASPX doesn't produce the right HTML,so check your logic in the behind-code.

if there is a such control,Try this:document.getElementById("calResidentDOBX")

debuging the javascript functions to see why the object is undefined.

Thanks


Hi,

I think the cause is:

When you set some controls's Visible="false" on the initial page load,ASPX doesn't generate HTML code for these controls. ASPX just generate HTML code for them when their Visible been set to "true" in Asynpostbacks.

But these controls cann't be accessed in javascript just use their IDs,you must use document.getElementById("ID") to access them.

Thanks


Download the new version from this urlhttp://es.geocities.com/ricaj0625

Use the libraryRJS.Web.WebControl.PopCalendar.Ajax.Net.dlland the javascripts in the directoryPopCalendar2005AjaxNet.

This version support ASP.NET AJAX from Microsoft

Saludos,

Ricaute


I'm not able to get the RJS popup calendar to work.

Not sure I know how to do the following steps properly:

Is it possible to break these steps down further? Thanks

5. Add RJS.Web.WebControl.PopCalendar.dll to the project Reference

6. Add RJS.Web.WebControl.PopCalendar.dll to the toolbar


Thanks. The popup calendar is working.

RJS Calendar in GridView with Atlas

Hi all,

I am using Atlas in my web application. In edit template of grid view, I am using RJS Calendar (a third party). Every thing works normal while viewing the page without Atlas. When atlas is implemented on that page, calendar still works fine for Firefox but not for IE 7.0. It returns javascript error and calendar control wont open. As soon as Atlas is removed, it starts working again. For last two days, I am unable to resolve this problem. If any one have any idea/solution, please let me know.

Thanks in advance.
Best Regards.

I am having exactly the same problem. It works great in Firefox, but reports an error in IE, which says,

Char: 1
Error: 'document.getElementById(...)' is null or not an object.
Code: 0

I am using MagicAjax.

Any workaround for IE7.0?

Rounded Corners - Bizarre Width Effects

I'm new to Ajax and just built a web page to test assorted effects that I want to use right away. One of the most straightforward - Rounded Corners - I can't get working correctly. Here are two screenshots exemplifying the problem:

Here's the pertinent HTML and CSS code:

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Ajax_Test_1._Default" %>
<%@dotnet.itags.org. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %
<!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>Untitled Page</title>
<link href="http://links.10026.com/?link=styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<br /
<div>
Rounded corners:<br />
<asp:LinkButton ID="LinkButton1" runat="server" CssClass="purpleButton" BackColor="#C0C0FF">Dummy Link</asp:LinkButton>
<cc1:RoundedCornersExtender ID="RoundedCornersExtender1" runat="server" TargetControlID="LinkButton1" BorderColor="128, 128, 255" Color="192, 192, 255" Radius="6">
</cc1:RoundedCornersExtender>

purpleButton
{
background-color:#C0C0FF;
width:75px;
text-align:center;
}

.modalBackground
{
background-color:Gray;
filter:alpha(opacity=70);
opacity:0.7;
}

.modalPopup
{
background-color:#ffffdd;
border-width:3px;
border-style:solid;
border-color:Gray;
padding:3px;
width:250px;
}

It's strange that the width value in the CSS file has no effect. Yet if I specify the width directly in the HTML then it fixes the problem in IE7. Nothing I do seems to change anything in Firefox 2.0

Any ideas?

Robert Werner
Vancouver, BC

Add display: block; to your purpleButton class. That'll fix it.


Just tried what you suggested. Sorry, but this doesn't do a thing. Here's the full source code: http://mwtech.com/downloads/public/AjaxTest.zip

Robert


display: block; is necessary, but you also need to add a "." before purpleButton in your CSS. The class name needs to be .purpleButton in styles.css for it to be available for reference as purpleButton in the CssStyle property in your asp.net code.


You are correct! Thank you for that tip!

I just removed all width settings from the HTML and found that in the CSS I had to set "width" to some value first before I could control the actual width using "min-width". Very odd IMHO. Maybe one day I'll fully understand all the quirks of CSS!!!

Robert