Showing posts with label extender. Show all posts
Showing posts with label extender. Show all posts

Monday, March 26, 2012

Centering Modal Popup Extender? (Edited)

Hello again,
I have a problem: i cant get a modal popup control to be centered!
The problem occures in some resolutions...
The control isn't in any divs or something like that, but i tried to put it in center aligned divs, no effect...
Edit:see last reply.

At 1280*1024 resolution, no problem:

(Link:http://www.intensitysoft.info/txtFiles/1280,1024.JPG)

At 14490,900 resolution, no problem:

(Link:http://www.intensitysoft.info/txtFiles/14490,900.JPG)

At 1280*800 resolution... BIG problem :):

(Link:http://www.intensitysoft.info/txtFiles/1280,800.JPG)

As you can see the panel is totally left...

Thanks for any help,
Liran.


The page seems to work fine in all my resolutions, but I don;t have 1280 X 800 available on any of my box's. Could you please post your code, maybe something will jump out.

-Alan


<%@. Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="products.aspx.cs" Inherits="Default4"%>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="AccessDataSource1">
<SeparatorTemplate>
<br />
</SeparatorTemplate>
<ItemTemplate>
<table cellpadding="0" cellspacing="0" style="width: 100%; height: 10px; border-top-width: 1px; border-left-width: 1px; border-left-color: #33cccc; border-bottom-width: 1px; border-bottom-color: #33cccc; border-top-color: #33cccc; border-right-width: 1px; border-right-color: #33cccc;">
<tr>
<td style="font-weight: bold; font-size: 16px; text-transform: none; color: black; font-family: Arial; background-color: #3399cc; text-decoration: none;" colspan="2">
<%# Eval("siteName") %></td>
</tr>
<tr style="background-color: lightblue; font-size: 14px; color: black; font-family: Arial;">
<td style="width: 133px; height: 90%">
<asp:ImageButton ImageUrl='<%# Eval("thumbPicSrc") %>' ID="ImageButton1" runat="server" />
</td>
<td style="height: 90%" valign="top">
<%# Eval("description") %></td>
</tr>
</table>

<ajaxToolkit:ModalPopupExtender OkControlID="imgOk" BackgroundCssClass="modalBackground" ID="ModalPopupExtender1" TargetControlID="ImageButton1" runat="server" PopupControlID="Panel1" />
<asp:Panel ID="Panel1" runat="server" style="display: none">
<asp:ImageButton ImageUrl='<%# Eval("picSrc") %>' ID="imgOk" runat="server" />
<br />
</asp:Panel>

</ItemTemplate>
</asp:Repeater>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="App_Data\instensUsersDB.mdb"
SelectCommand="SELECT * FROM [sites]"></asp:AccessDataSource>
<asp:ScriptManager id="ScriptManager1" runat="server" />

<br />

<br />
</asp:Content>


Just found out that the problem doesn't occur because of the resolution, it occures because of the browser!
With Internet Explorer 7 everything is fine, so on with FireFox... but with I.E. 6, it's just doesnt work.

Any solution?
Liran.

Catching form Submit and PageRequestManager Submit

We want to save some state on an Extender just before the page is posted back or submitted. We were just listening to the form's submit event

$addHandler(form,"submit", this._formSubmitDelegate);

but that doesn't fire when we postback is via a LinkButton so I want to catch that happening and reuse the same delegate.

I looked at using

 $addHandler(Sys.WebForms.PageRequestManager.getInstance(),'endrequest',this._endRequestDelegate);

but add Handler did not like non DOM elements being passed in. I then tried

 Sys.WebForms.PageRequestManager.getInstance().add_endRequest(this.endRequestHandler);
But the value of "this" was not what I was expecting. I am currently trying
if (typeof(Sys.WebForms)!=="undefined" &&typeof(Sys.WebForms.PageRequestManager)!=="undefined"){ Array.add(Sys.WebForms.PageRequestManager.getInstance()._onSubmitStatements,this._formSubmitDelegate); }else { $addHandler(form,"submit",this._formSubmitDelegate); }

This seems to call formSubmitDelegate and all works well. I realise i am accessing _onSubmitStatements which should be considered private. Am I cheating? What is the correct way of doing it?

TIA

Paddeo

Hi Paddeo,

Why the second one doesn't meet your requirement?

It's the recommended way that how a handler is added.


Well when my page is "Posted back" and that postback is caused by something causing validation WebForm_DoPostbackWithOptions is called. At the end of that routine it passes off to a ASP.NET AJAX routine that will do the "postback" using a WebRequest. That does NOT cause our Form Submit event to fire.

I thought I could get around this by trapping both the Submit AND adding to the _onSubmitStatements array (I realise that my eariler post was doing it OR the other) however this is still not enough. If I had a simple AutoPost=True ASP.Net CheckBox that calls _doPostback that exists in the page itself. This does not cause my onSubmitStatements to fire nor does it call DoPostbackWithOptions so yet again I have an issue with reliably catching postbacks and submits.

To this end I am going to give up trying to lazy write to state and just serilaise it every time it changes.

Pat


Saving client state on PropertyChanged event.


Yes, sorry I should have reported back. PropertyChanged is exactly what i changed to and that works much better. Even the approaches above were not enough to catch all the postbacks

Catching an event from an Extender

I have written an extender and have everything working but catching an event in my .aspx page.

What is the recommended way for me to send a notification back to the application that something has happened in the extender and the page hosting the extender can take some action if it wants to?

I get the following alerts based on the code below

Client hooking into change -- at startup

add_changed -- at startup

raiseEvent: change -- when a change occurs

I have tried to use something like the following.

Control hookup in .aspx page

<psAjax:SampleExtender ID="sampleExtender" runat="server" TargetControlID="_tbName" Timeout = "250" BehaviorID="sampleExtenderBehavior"/>

Script in .aspx page

function linkBehavior()

{

var myBehavior = $find("sampleExtenderBehavior");

if (myBehavior)

{

myBehavior.add_changed(change);

}

}

function change () //This never fires

{

alert('aspx change');

}

Script in my extender .js file

add_changed : function(handler)

{

alert('add_changed');

this.get_events().addHandler('change', handler);

},

raiseEvent : function(eventName, eventArgs)

{

alert('raiseEvent: ' + eventName);

var handler = this.get_events().getHandler(eventName);

if (handler)

{

alert('Found raiseEvent: ' + eventName);

if (!eventArgs)

{

eventArgs = Sys.EventArgs.Empty;

}

handler(this, eventArgs);

}

},

I found my problem... I was not calling the linkBehavior method from pageLoad so a new behavior was created and destroyed when I called it.

I have since modified that approach and I am now registerting the event when a property is changed and this seems to work.

Is something like the following a valid way of doing things?

aspx code

<psAjax:TextChangedExtender ID="TextChangedExtender" runat="server" TargetControlID="_tbName" Timeout="250" TextChangedFunction = "onTextChanged" />

function onTextChanged()
{
alert('Client Side onTextChanged');
}


Extender .js

set_TextChangedFunction : function(value)
{
if (value != this.textChangedFunction)
{
this.remove_TextChangedHandler();

this.textChangedFunction = value;

var fn = new Function('return ' + this.textChangedFunction + '(); ');

this.add_textChanged(fn);

this.raisePropertyChanged('OnTextChanged');
}
},

Saturday, March 24, 2012

CascadingDropDownlist: How Do I Save the SelectedValue Back To Database

I'm using the AJAX CascadingDropDown extender inside a FormView's InsertItemTemplate.
Question: What is the correct way to save the CascadingDropDown 's selected value back to the database?

I've tried do it by setting the SelectedValue in the CascadingDropDown tag (not the DropDownList) like this:
SelectedValue='<%# Bind("SellerRegionId") %>'

However, when trying to save, this fails with error "Input string was not in a correct format."

I've been able to make it work by setting the Values dictionary in the FormView's ItemInserting() event handler, using the SelectedValue of the DropDownList control (not the extender), as follows:
e.Values["SellerRegionId"] = sellerRegionDropDownList.SelectedValue;

Is this the correct way to do this?

Thanks, in advance, for any help you can give.

Yes the latter should work and in my own opinion personally is more efficient.

CascadingDropDownList problem !

Hi there, I'm in trouble with cascadingDropDownList extender.

I use webMethod to make connection to a SQL database, actually methods work fine and get results in XML form in test page. However, when I make call from the cascadingDropDownLists at the .aspx page, It only gets a "Method error 500"

Here is the code

---.ASPX---

<%@dotnet.itags.org.PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"EnableEventValidation="false" %>

<%@dotnet.itags.org.RegisterAssembly="AtlasControlToolkit"Namespace="AtlasControlToolkit"TagPrefix="atlasToolkit" %>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title>Untitled Page</title>

</head>

<body>

<formid="form1"runat="server">

<atlas:ScriptManagerID="ScriptManager1"runat="server"/>

<div>

<asp:DropDownListID="DropDownList1"runat="server">

</asp:DropDownList>

<asp:DropDownListID="DropDownList2"runat="server">

</asp:DropDownList>

<atlasToolkit:CascadingDropDownID="CascadingDropDown1"runat="server">

<atlasToolkit:CascadingDropDownProperties

TargetControlID="DropDownList1"

Category="MarkaTitle"

ServicePath="http://localhost:3631/CDDWebService/Service.asmx"

LoadingText="Please Wait..."

PromptText="Select a Marka..."

ServiceMethod="getMarka">

</atlasToolkit:CascadingDropDownProperties>

<atlasToolkit:CascadingDropDownProperties

TargetControlID="DropDownList2"

Category="ModelTitle"

ServicePath="http://localhost:3631/CDDWebService/Service.asmx"

ParentControlID="DropDownList1"

ServiceMethod="getModel"

PromptText="Select Model..."

LoadingText="Please Wait...">

</atlasToolkit:CascadingDropDownProperties>

</atlasToolkit:CascadingDropDown>

</div>

</form>

<scripttype="text/xml-script">

<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">

<references>

</references>

<components>

</components>

</page>

</script>

</body>

</html>

/---.ASPX---

--WebService Codes--

using System;

using System.Web;

using System.Web.Services;

using System.Configuration;

using System.Web.Services.Protocols;

using AtlasControlToolkit;

using System.Collections;

using System.Collections.Generic;

using System.Collections.Specialized;

using System.Data;

using System.Data.SqlClient;

[WebService(Namespace ="http://Boss.com.tr/",Name="CDDWS")]

[WebServiceBinding(ConformsTo =WsiProfiles.BasicProfile1_1)]

publicclassService : System.Web.Services.WebService

{

string myConnectionString =ConfigurationManager.ConnectionStrings["VehiclesConnectionString"].ToString();

public Service () {

//Uncomment the following line if using designed components

//InitializeComponent();

}

[WebMethod]

publicCascadingDropDownNameValue[] getMarka(string knownCategoryValues,string category)

{

SqlConnection dbConnection =newSqlConnection(myConnectionString);

SqlDataAdapter myAdapter =newSqlDataAdapter("select * from MarkaTbl", dbConnection);

DataTable myTable =newDataTable();

try

{

myAdapter.Fill(myTable);

}

catch (Exception ex)

{

//throw ArgumentException("not valid");

}

List<CascadingDropDownNameValue> values =newList<CascadingDropDownNameValue>();

foreach (DataRow drin myTable.Rows)

{

values.Add(newCascadingDropDownNameValue((string)dr["MarkaTitle"],dr["MarkaID"].ToString()));

}

return values.ToArray();

}

[WebMethod]

publicCascadingDropDownNameValue[] getModel(string knownCategoryValues,string category)

{

SqlConnection dbConnection =newSqlConnection(myConnectionString);

SqlDataAdapter myAdapter =newSqlDataAdapter("select * from ModelTbl", dbConnection);

DataTable myTable =newDataTable();

try

{

myAdapter.Fill(myTable);

}

catch (Exception ex)

{

}

List<CascadingDropDownNameValue> values =newList<CascadingDropDownNameValue>();

foreach (DataRow drin myTable.Rows)

{

values.Add(newCascadingDropDownNameValue((string)dr["ModelTitle"], dr["ModelID"].ToString()));

}

return values.ToArray();

}

}

/--WebService Codes--

One more question; I couldn't understand exactly what is "category", and what it is stands for. I considered it is as fieldName of at the database :)

Thanks for any help ...

At least, can someone tell me what is "category" in CascadingDropDown extender ?

Hi BossDida,

You're getting a message returned by the ASP.NET AJAX Extensions indicating "there was a problem with your web service." I'd take a look at the CascadingDropDown.aspx sample page to see how what you're doing differs from it.

Also, the category (as described in the CascadingDropDown sample page) is used to indicate to the web service which drop down is asking for data (because you can have all your drop downs hit the same webmethod if you wanted).

Thanks,
Ted

CascadingDropDownExtender - preselected value

I used the dropdown extender a lot and noticed now a strange behavior, that makes it kind of a showstopper, if there is no workaround:

I have three DropDownLists exactly like in the example of the Toolkit. Except for the first DropDownList all values are filled in via the DropDownExtender. I did not use the optional PromptText property, because I do want to have the first value in each DropDownList preselected. This looks OK, so if I change the value of the first DropDownExtender, the values update in a cascade and the first item of each dropdown seems to be preselected - perfect. But if a postback happens now, the actual DropDownLists are empty and no value is selected, they are only selected, if the user would go on and open the drop down list and really select a value only then the values are also visible on the server side.

Is there any method I could call on the extender or on the dropdownlist to make the values visible on the server after a postback without having the user to click on the combobox and select the same value he already sees? That would be kind of hard to explain...

The behavior is easily to reproduce with the example from the Toolkit, just change in CascadingDropDown.aspx

 <table> <tr> <td>Make</td> <td><asp:DropDownList ID="DropDownList1" runat="server" Width="170" /></td> </tr> <tr> <td>Model</td> <td><asp:DropDownList ID="DropDownList2" runat="server" Width="170" /></td> </tr> <tr> <td>Color</td> <td><asp:DropDownList ID="DropDownList3" runat="server" Width="170" AutoPostBack="true" /></td> </tr> </table> <asp:Button ID="Button1" runat="server" Text="Button" UseSubmitBehavior="false" OnClick="DropDownList3_SelectedIndexChanged" /> <br /> <ajaxToolkit:CascadingDropDown ID="CascadingDropDown1" runat="server" TargetControlID="DropDownList1" Category="Make" ServicePath="CarsService.asmx" ServiceMethod="GetDropDownContents" /> <ajaxToolkit:CascadingDropDown ID="CascadingDropDown2" runat="server" TargetControlID="DropDownList2" Category="Model" ServiceMethod="GetDropDownContentsPageMethod" ParentControlID="DropDownList1" /> <ajaxToolkit:CascadingDropDown ID="CascadingDropDown3" runat="server" TargetControlID="DropDownList3" Category="Color" ServicePath="~/CascadingDropDown/CarsService.asmx" ServiceMethod="GetDropDownContents" ParentControlID="DropDownList2" />

ups... always learning... there is a "isDefault" flag on the CascadingDropDownValue collection, that just has to be set... problem solved!

CascadingDropDown: Pulling selected values from a cookie

I am using the CascadingDropDown extender from the AjaxControlToolkit and I was wondering if there was an easy way to set the selected value and to populate child drop downs when the page loads. I am storing a users previous selections in a cookie so when they start a new form these values are already selected. I did some looking at the CascadingDropDown code but I didn't see an easy way to accomplish this. Does anyone know an easy way to do it?

Or am I going to have to cobble some JS together to make it happen?

Thanks.

Derek

Couldn't you just do something like

myCascadingDropdownListExtender.SelectedValue = Request.Cookies("MyCookie")

on Page_Load ? It works for me.

CascadingDropDown With more then one parameter?

I am trying to use the CascadingDropDown drop down extender in a DataView.

I have three drop-downs where ddl1 contains the main lookup value. When I select ddl1, the second dropdown ddl2 populates perfectly. The problem that I have however is that the 3rd drop down is dependent on both the selected value in ddl1 and another value/column in the row. Does anyone know whether this is achievable with the CascadinDropDown extender at all? I guess i need a way to make the web service have more parameters and a way to pass the parameters to the webservice.

Any help would be highly appreciated!!

Does anyone know how I can get the Cascading DropDowns to have more then one parent id. I really need to figure out how to make the third drop down populate based on the value selected in the 1st drop down and another value from the grid... this must be acheivable.. I can't be the only one trying to do this...


Sorry, this scenario is not currently supproted by CDD.

Wednesday, March 21, 2012

CascadingDropDown official example from ASP.net not running properly

Hi all, yesterday I tried to use CascadingDropDown extender for the first time and it didnt work. I have closely followed both the video tutorial and the sample website. I have 2 chained dropdownlists, 1 of them is supposed to be disabled until the other is selected right? However, when I run the web app, both of the dropdownlists are enabled from beginning, selecting value in the parent DDL doesnt load the values in the child DDL.

So I downloaded the code from the official ASP.net tutorial to see what I have done wrong. To my surprise, the sample website didnt work either, showing the same symptom! I downloaded and installed the latest Toolkit but that did not help. Does anyone know what is happening?

Thanks,

Phuong.

By the way, the webmethod that populates data into the parent dropdownlist did work. The parent dropdownlist did get the correct data.


Please help!


Hi Phuong,

It's hard to tell the reason since the sample code doesn't work too.

The only suggestion I can make is downloading the most recent AjaxControlToolKit and sample and try again.