Showing posts with label net. Show all posts
Showing posts with label net. Show all posts

Wednesday, March 28, 2012

control inside an update panel not updated

i have a dropdown list inside an update panel of ajax, i have a button that says "Add" on the click event of the button i will load a pop-up screen. the popup screen works as entry area of the drop down list i have mentioned. upon saving and unloading the pop-up screen, it should update the dropdown list contents. any help please, this is my first time to handle ajax..

Hi,

You question is about cross window scripting.

First, find the dropdownlist in the parent control.

var ddl = window.opener.document.getElementById("id of the ddl");

then add new item into it:

ddl.options.add("new value");

Hope this helps.

Control inside a DropDownList

Hi,

Is it possible to insert controls such as buttons, etc... inside a dropdownlist ?

hello.

not inside the traditional dropdownlist. i guess that you could fake it though by using javascript...


thank you

Control ID Changed and GetElemntByID Return NUll

I have this code

<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<asp:TextBox ID="TxURL" runat="server"></asp:TextBox>
<asp:Button ID="Test" runat="server" Text="Button" OnClick="Test_Onclick" />
</ContentTemplate>
</asp:UpdatePanel>

I try to run this script

var TextControl= document.getElementByID("TxURL")

or

var TextControl = $get("TxURL")

but return value is NULL.

so How, to get Item in Client with the orignal Name. not the generated Name

Thanks.

U may be using Master Pages or UserControl thats why the client id of the control are not the same which u give to the control on the design time

try to run this script

var TextControl= document.getElementByID("<%= TxURL.ClientID %>")

or

var TextControl = $get("<%= TxURL.ClientID %>")

Control focus on autopostback in UpdatePanel

I have an Update Panel with a bunch of textboxes, and have code for the _onTextChanged events of some of them, so I have enabled AutoPostBack=true.
This is a data entry screen, so the TabIndex is critical. In Mozilla, when the textbox posts back, the TabIndex moves to the next box as expected. In IE, the reload of the page seems to reset the TabIndex to the first textbox.

Any ideas on how I can make my code behave in IE like it does in Mozilla?

ThanksActually, I asked same question yesterday. Unfortunately, no answers yet.
You could use Control.Focus(), to manually set the focus to the next control (either in the server code or with javascript).
That's the strange thing about it... I already had that, and I watch it work in stepping through the _onTextChanged of the control, but then the focus just gets changed/set to nothing after my code set it properly...

Control Focus Inconsistent in Updatepanel on Update

Hi,

Any help would be appreciated in regards to the following problem:

I'm creating calculator-type applications and having problems with focus being lost from textbox controls that are inside of UpdatePanels when my UpdatePanels refresh. Because of the nature of the calculators, all of my textbox fields need to be inside of the update panel. As each textbox is filled out (which can be done in any order) other textbox values will change and adjust. This is all done using the July CTP of Atlas, and the TextChanged events of the TextBox controls.

My problem is that once a user changes the value of a textbox, the UpdatePanel refreshes (to adjust the other textboxes) causing the cursor to unfocus from the newly selected TextBox.

Thus, if the user tabs into a textbox in my UpdatePanel and adjusts the value, then presses tab again, their cursor will momentarily highlight the next textbox and then disappear entirely when the UpdatePanel is updated.

Thanks!

-Snickers

Use Javascript to do calculations and avoid code behind . your problem will be solved.

if there is some connectivity with database or some major code then use code behind

hope it helps

http://www.devguru.com/technologies/javascript/home.asp

Control Focus in ASP.Net 2.0 using AJAX, Master Pages, user controls...

Having a heck of a time with this... Any assistance would be appreciated. All I need to do is set focus to a textbox control that is inside an AJAX tab container (has 2 tabs) that is inside a user control that is inside the content page of a master page. I've tried everything from setting the default focus in the master page to calling .focus() on the textbox to custom javascript and cant get anything to work. Is there something I'm missing here? I'd like to somehow set the focus at the content page level if possible.

Thanks,Troy

I usually set the focus by custom javascript and not use any asp.net built-in feature for this.

I use this javascript function:

function setFocus( id )
{
var o = document.getElementById( id );
if(o != null && !o.disabled ) { o.focus(); }
}

And I have this just before closing the body tag, but can be other place:

<script type="text/javascript">

setFocus( "yourcontrolid" );

</script>

The real question is how to get the corrent id for your control?

You can do this for example:

setFocus( '<%= yourcontrol.ClientID %>' );

You can also hard-code the control id, you can find-out your correct control id by examining the source view of your html page (if the control is rendered during an async postback the page source view not reflect the changes, you need some debugging tool to see your real html source, firebug etc.)


Hadn't thought of inline script. I tried the above, but am still getting the following error: guessing it's an AJAX tab container thing:

"htmlfile: Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus."

Here's what I did: Exposed the textbox's clientID in a string property from the child control; Added setFocus(id) sccript to the master page's head tag;At the end of the content page's Page_Load event (server), added aRegisterStartupScript for setFocus passing in the clientID property.

When debugging the above error, my textbox (Input element) makes it into the setFocus() function, is enabled, etc, etc, ... ??

I'll continue to search on the above error. Thanks for the input stmarti...


Found a workaround. (seehttp://forums.asp.net/t/1184754.aspx?PageIndex=3) I ran across this before but am using it as a last resort... "Slowing down" the app doesnt seem like the correct solution but will have to do. I worked a delay routine into the setFocus() solution stmarti suggested. Did the same as above with the following changes in the master page (and calling delay using RegisterStartupScript in content's page_load instead of setFocus):

function delay(id){setTimeout("setFocus('"+id+"')",500);

}

function setFocus( id ) {

var o = document.getElementById( id );if(o !=null && !o.disabled ) { o.focus(); }

}

Anyone with a more elegant solution, please post. Thanks!


What about this (no delay required I think)?

<script type="text/javascript"
Sys.Application.add_load( function( )
{

var o = document.getElementById( yourid );

if(o !=null && !o.disabled ) { o.focus(); }


} );


</script>

You can try other events also (ASP.NET AJAX > Overview > ASP.NET AJAX Client Life-Cycle Events )


Looks like the above is what I'm looking for - wont get a chance to investigate for a bit. Thanks!

Control Extenders inside View Templates?!?

In the previous versions of the toolkit I could place a control extender inside a view template and everything worked just fine but with today's release (10-20-2006) this appears to have broken.

I have verified this to be true with the TextBox Watermark Extender, the Drop Shadow Extender, and the Rounded Corners Extender.

As an example:

<asp:ScriptManager ID="scriptManager" runat="server" />
<asp:LoginView ID="loginView" runat="server">
<AnonymousTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<ajaxToolkit:TextBoxWatermarkExtender ID="tbw" runat="server" TargetControlID="TextBox1" WatermarkText="WaterMark" />
</AnonymousTemplate>
</asp:LoginView>

This code worked fine in the last version but in this version I do not see the watermark.

Is anyone else experiencing this? If there another way to do this?

Thanks

Sean

The fix is to add the following to your page:

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
loginView.DataBind();
}

The reason is outlined here:http://forums.asp.net/thread/1441672.aspx.

Control extenders and dispose

I'm having a problem using multiple control extenders on a single web control. The control is a table, and I have two custom extenders (which inherit from ExtenderControl) extending the table. Both of these extenders add event handlers to both the table and window. The problem I'm having is that the dispose method (which MUST be called to remove the window events on an asynchronous postback) is only being called on ONE of the extenders. This seems to always be the most recent extender (in markup - I've tried switching the order that the extenders are defined in markup to verify this behavior). On a full page postback, both dispose methods are always called. Is this some kind of bug? Or is there something I am doing wrong in my extender implementation(s)? I really can't post the full code of my extenders, but if neccessary I can try to create a simple example that displays the behavior.

Ouch - nobody has any idea? Should this maybe be posted in a different forum? Any additional info I can add? This is really causing me problems in my current project...

Control Extender, but not a Behavior

Hey All,

I was wondering if it is possible to create a Control Extender that does not render a behavior, but renders binding information instead. From what I've seen, this doesn't seem to be possible and the way I should do this is to implement IScriptControl and then code my own extender per say.

Anybody else doing something like this?

Thx

IScriptControl will get you there - you'll just have to render out all the script manually...


Ok ... that's the path I was heading down.

If I have a control that's markup is like the following

...

<asp:Button id="button1" runat="server" text="Text" /
<Ext:BindingModifier id="BM1" runat="server">
<Ext:BindingModifierProperties TargetControlID="button1" />
</Ext:BindingModifier
can it still be considered an extender or are we just talking about something else at this point?

Generalizing my question, what's the definition of an Extender? Must it emit a behavior?

Thx for the help and being so active on the boards.

Well that's an extender for sure. What XML are you looking to emit exactly?


I'm looking to emit binding information that ties a series of controls to _PageRequestManager's "inPostBack" property.

The point is to disable a series of controls during a postback.

An example of the code I'm looking to emit can be foundat this post.

Thx
Yeah we don't help you too much there. Your other option it so instanitate a behavior that does this instead, either directly (e.g. finds the disabled property and toggles it) or by adding the bindings via the Atlas object model directly.
Ok ... we're going to mimic the way to write the markup of an extender because it makes sense, but implement IScriptControl to handle all of the script output.

Any thoughts on future plans on creating a pre-built library / project template to do something with other sections of xml-script other than behaviors?

control extender for drag and drop - help

I am trying to get drag and drop to work with data dynamically populated from a database. The basic structure layout of the page is based on the work done by Garbin at:

http://aspadvice.com/blogs/garbin/archive/2006/01/17/14730.aspx

I have a master page and some user controls to populate different areas of the page. One of the user controls gets the data from the database and then creates the HTML of the form:

<div id="content1" class="item"> <div id="content1Handle" class="itemHandle">Content 1</div> <div class="itemContent"> <asp:Login ID="myLogin" runat="server" CssClass="centered"></asp:Login> </div> </div> <div id="content2" class="item"> <div id="content2Handle" class="itemHandle">Content 2</div> <div class="itemContent"> <asp:TextBox ID="myTextBox" runat="server"></asp:TextBox> <asp:Button ID="myButton" runat="server" Text="ClickMe" /> </div> </div>

This works OK, but to create the drag and drop behavior, I need to add the following after the end of the </form> tag …

</form> <script type="text/xml-script"> <page> <components><!-- Left Area --> <control id="leftArea"> <behaviors> <dragDropList dataType="HTML" acceptedDataTypes="'HTML'" dragMode="Move" direction="Vertical"> <dropCueTemplate> <template layoutElement="dropCueTemplate" /> </dropCueTemplate> <emptyTemplate> <template layoutElement="emptyTemplate" /> </emptyTemplate> </dragDropList> </behaviors> </control><!-- Right Area --> <control id="rightArea"> <behaviors>

BUT, I do not know how … it has been suggested that I use a control extender, but having viewed the ATLAS vids on the MS website, I cannot understand how a control extender will be able to dynamically create this code after the </form> tag ?

Any ideas anyone ?

Thanks

anyone ? please ... Crying

Control Events in Accordion

I have an accordion control which contains several panes each containing a GridView (by using ConentTemplate). I would like to give the user the ability to edit GridView items inline. The problem is that I must click twice to put the item into edit mode. I have seen other posts with similar problems but no definite solution. Any help would be greatly appreciated.

1 <ajaxToolkit:Accordion ID="Accordion1" runat="server" HeaderCssClass="accordionHeader"2 ContentCssClass="accordionContent" SelectedIndex="0"3 AutoSize="None" FadeTransitions="false" FramesPerSecond="40" TransitionDuration="250" EnableViewState="true" >4567 <HeaderTemplate><a class="accordionLink" id="accordionLink" href="http://links.10026.com/?link=" onclick="return false;"><%# ((Person)((DictionaryEntry)Container.DataItem).Key).FirstName + " " + ((Person)((DictionaryEntry)Container.DataItem).Key).LastName%></a></HeaderTemplate>89 <ContentTemplate>10111213 <asp:GridView EnableViewState="true" ID="GridViewOpen" OnRowUpdating="GridViewOpen_RowUpdating" OnInit="GridViewOpen_Init" OnRowEditing="GridViewOpen_RowEditing" OnRowCancelingEdit="GridViewOpen_RowCancelingEdit" OnSelectedIndexChanged="GridViewOpen_SelectedIndexChanged" runat="server" DataSource="<%# ((DictionaryEntry)Container.DataItem).Value%> "14 AutoGenerateColumns="false" AutoGenerateEditButton="true" AutoGenerateSelectButton="false" AllowSorting="true">15 <Columns>16171819 <asp:TemplateField HeaderText="MoNumber" SortExpression="MoNumber">20 <EditItemTemplate>21 <asp:TextBox ID="LabelEditMoNumber" runat="server" Text='<%# Bind("MoNumber")%>'></asp:TextBox>22 </EditItemTemplate>23 <ItemTemplate>24 <asp:Label ID="LabelViewMoNumber" runat="server" Text='<%# Bind("MoNumber")%>'></asp:Label>2526 </ItemTemplate>27 </asp:TemplateField>2829303132 <asp:TemplateField HeaderText="Location" SortExpression="LocationId">33 <EditItemTemplate>34 <asp:DropDownList runat="server" id="dataLocationId" DataSourceID="objDsLocationId" DataTextField="Name" DataValueField="LocationId" SelectedValue='<%# Bind("LocationId")%>'></asp:DropDownList>35 </EditItemTemplate>36 <ItemTemplate>37 <asp:Label ID="Label2" runat="server" Text='<%# FindLocation(Eval("LocationId"))%>'></asp:Label>38 </ItemTemplate>39 </asp:TemplateField>40 <asp:TemplateField HeaderText="Time (Hrs)">41 <ItemTemplate>42 <asp:Label ID="Label3" runat="server" Text='-'></asp:Label>43 </ItemTemplate>44 </asp:TemplateField>4546474849 </Columns>50 </asp:GridView>5152 </ContentTemplate>5354 </ajaxToolkit:Accordion>


I too have this problem with a normal LinkButton
Same problem here too, and it's driving me bonkers :(
I see you are not using panes inside the accordion. Is this because you only need one pane? I thought you'd need one pane for every GridViewConfused
In my project, I am using Panes and I'm still having issued. All the Panes are being loaded dynamically though, which I need to do that way. Any ideas out there?

All I have the solution, it dosen't make sence but it solves the problem

at the page Load create a pointer to the control for example

Dim btnAs Button =CType(Accordion1.Panes(0).FindControl("btnQuickSearch"), Button)

Where btnQuickSearch is the id of the button

Good Luck


This seems like a common problem.

The example above works for an accordion with only one pane. However, if I do the same to try and initialize controls in the second, or third pane it doesn't work. I can reference the controls in my code, however I still have to click a button twice to fire the event.

Does anyone have any thoughts on how to avoid this? Or, can I catch the accordion transition event (if there is one) and then initialize my controls for that pane in that event?

This one has me stumped.


I'm having almost the exact same issue. I am creating what is essentially a datagrid-accordion where each line of the control is an accordion panel. I managed to get sorting and paging to work, but they are outside the actual accordion control. I can't make the controls inside the accordion pane to trigger their appropriate event. At one point I was able to have them fire on the second click, but after adding a command name and command argument to the buttons, they don't do that anymore.

I would also like to be able to have a 'cancel' button that closes the panel, but nothing is working. The cancel button could be done with javascript, but no one seems to know how to do this. Are there no solutions to these problems? I don't want to have to make with a complicated work around where I have to create the buttons inside the accordions data bind event... its way more hassle than its worth.

Thanks


Yup I'm where you're at as well. It's a little silly that just getting buttons to work in an accordion can be so complex haha.

I have gotten buttons to work, but only when I manually create the accordionpanes and do the oninit() trick. That's not we want of course, there must be a way to wire up a databound accordion to get control events to fire. I don't know how to tap into an accordionpane's oninit function when they are created through databinding though, does anyone have a solution?

- Calvin


So far the best I can do is get the double click effect on a databound accordion. Add a empty panel and set its visibility to false, and you get the problems noted herehttp://forums.asp.net/t/1017782.aspx. But the fixes they talked about don't seem to work for the databound panels.

If I get any farther with a work around I will let you all know.


Ok, so what I came up with was to actually change the source code. Its not a lot to change, but its not 100% perfect.

Also, I can't take credit for this, because I gathered the combined changes required from various sources, but here it is:

TheAccordion Class needs to be changed from aWebControl to aCompositeControl.

source:here

And both theAccordion Class and theAccordion Panel Class need to use theINamingContainer.

source:here

Here is an example of the change:

was:public class Accordion : WebControl

is now:public class Accordion : CompositeControl, INamingContainer

Hope this helps some people.


I made the change but now clicking buttons makes the entire accordion disappear. I'm not positive it's due to changing the base to compositecontrol though, because I was fiddling with a ton of other stuff before I caught your post. It's way too late in my project to try to keep messing around with the control however, so it's back to old school repeaters for me.


CalZ:

I made the change but now clicking buttons makes the entire accordion disappear. I'm not positive it's due to changing the base to compositecontrol though, because I was fiddling with a ton of other stuff before I caught your post. It's way too late in my project to try to keep messing around with the control however, so it's back to old school repeaters for me.

I had that issue as well... where are you doing the databind?


I'm binding it in the markup:

<cc1:Accordion ID="AccordionResults" runat="server" DataSourceID="SqlDataSourceResults" SelectedIndex="-1" RequireOpenedPane="false" FadeTransitions="true" OnItemCreated="InitPanes" HeaderCssClass="accordionHeader" HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent" Width="800px">

And onItemCreated calls:

Protected Sub InitPanes(ByVal sender As Object, ByVal e As AjaxControlToolkit.AccordionItemEventArgs)

Dim myAccordionPane As AjaxControlToolkit.AccordionContentPanel = CType(e.AccordionItem, AjaxControlToolkit.AccordionContentPanel)
Dim workAroundLabel As New Label
workAroundLabel.Visible = False
myAccordionPane.Controls.Add(workAroundLabel)

End Sub


Well, before I make any suggestions, realize I am not an expert at this by any measure. But when I experienced the same symptoms, it was because I was Adding controls before I was binding the data (so adding controls to an accordion with no panes), or at least thats what I thought.

Looking at you're code, my only suggestion is that you remove the work around label and give it one last try.

Sorry I cant be of more help.

Control dont work

I have a form with some fields inside a UpdatePanel. And I also have some panels that I'm using as modal panels (just like in the Atlas Control Toolkit examples).

Thats the modal code:

1 <atlasToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server">
2 <atlasToolkit:ModalPopupProperties TargetControlID="btnGravar" PopupControlID="pnlContPag" BackgroundCssClass="modalBackground" DropShadow="true" CancelControlID="btContpagCancela"/>
3 <atlasToolkit:ModalPopupProperties TargetControlID="btnDeletar" PopupControlID="pnlDelete" BackgroundCssClass="modalBackground" DropShadow="true" OkControlID="btnDelSim" CancelControlID="btnDelNao"/>
4 </atlasToolkit:ModalPopupExtender>

My Problem is: When I try the modals when the fields are empty, the buttons works. But when I load data from the database into the fields, the modal works, but the buttons inside its panels dont!!!

I'm almost getting insane!!

Could anybody help me ?Here is it.
I have a panel called pnlDelete, which have 2 buttons. One of them kills the record, the other does nothing.
The problem is: The buttons do not work!

1<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>23<%@. Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="atlasToolkit" %>45<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">67<html xmlns="http://www.w3.org/1999/xhtml" >8<head runat="server">9 <title>Transufos::Servi?os de Oficina</title>10 <style>11 .modalBackground {12 background-color:Gray;13 filter:alpha(opacity=50);14 opacity:0.5;15 }16 .modalPopup {17 background-color:#ffffdd;18 border-width:3px;19 border-style:solid;20 border-color:Gray;21 padding:3px;22 }23 </style>24</head>25<body>26<form id="form1" runat="server">27 <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="XX-Large" ForeColor="Blue"28 Style="z-index: 108; left: 8px; top: 477px" Width="336px">Servi?os de Oficina</asp:Label><br />2930 <atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />31323334 <atlas:UpdateProgress ID="UpdateProgress1" runat="server">35 <ProgressTemplate>36 <asp:Panel ID="Panel1" runat="server" Height="55px" Width="173px" BackColor="LightYellow" style="z-index: 999; left: 248px; position: absolute; top: 285px" BorderStyle="Solid" BorderWidth="2px" BorderColor="DarkRed">37 <asp:Image ID="Image2" runat="server" ImageUrl="~/animated_loading.gif" Style="z-index: 100;38 left: 23px; position: absolute; top: 22px" />39 <br />40 <strong>41              42 Carregando ... </strong>43 </asp:Panel>44 </ProgressTemplate>45 </atlas:UpdateProgress>464748 <atlas:UpdatePanel runat="server" ID="UpdatePanel1" Mode="Conditional">4950 <ContentTemplate>5152 <br />53 <br />5455 <asp:Label ID="lblMessage" runat="server" ForeColor="Red" Style="left: 24px; top: 970px"56 Width="708px" Height="37px"></asp:Label><br />57585960 <div style="display:none">61 <asp:Panel ID="pnlDelete" runat="server" BackColor="Salmon" BorderColor="Red" BorderStyle="Solid"62 BorderWidth="2px" Height="80px" Style="z-index: 112; left: 780px; position: absolute;63 top: 444px" Width="328px">64 <p align="center">65 <strong><font color="#000000">Este registro será EXCLUíDO. Tem certeza?</font></strong></p>66 <p align="center">67 <asp:Button ID="btnDelSim" runat="server" BackColor="White" CausesValidation="False"68 Font-Bold="True" ForeColor="Red" OnClick="btnDelSim_Click" Text="Sim" BorderStyle="Outset" />69               70 <asp:Button ID="btnDelNao" runat="server" BackColor="White" CausesValidation="False"71 Font-Bold="True" ForeColor="Red" OnClick="btnDelNao_Click" Text="N?o" /></p>72 </asp:Panel>73 </div>838485<!-- Modais //-->86 <atlasToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server">87 <atlasToolkit:ModalPopupProperties TargetControlID="btnGravar" PopupControlID="pnlContPag" BackgroundCssClass="modalBackground" DropShadow="true" CancelControlID="btContpagCancela"/>88 <atlasToolkit:ModalPopupProperties TargetControlID="btnDeletar" PopupControlID="pnlDelete" BackgroundCssClass="modalBackground" DropShadow="true" OkControlID="btnDelSim" CancelControlID="btnDelNao" />89 </atlasToolkit:ModalPopupExtender>90<!-- Fim dos modais //-->9192939495 <asp:LinkButton ID="btnConsultar" runat="server" BackColor="Transparent" CausesValidation="False"96 Font-Bold="True" ForeColor="Black" OnClick="btnConsultar_Click" Style="left: 750px;97 position: absolute; top: 138px">Consultar</asp:LinkButton>98 <asp:LinkButton ID="btnGravar" runat="server" BackColor="Transparent" Font-Bold="True"99 ForeColor="Black" OnClick="btnGravar_Click" Style="left: 758px; position: absolute;100 top: 212px" TabIndex="34" Width="45px">Gravar</asp:LinkButton>101 <asp:LinkButton ID="btnDeletar" runat="server" BackColor="Transparent" CausesValidation="False"102 Font-Bold="True" ForeColor="Black" OnClick="btnDeletar_Click" Style="left: 758px;103 position: absolute; top: 286px">Deletar</asp:LinkButton>104  105 </ContentTemplate>106107108 </atlas:UpdatePanel>109110</form>111</body>112</html>

thankx
Please post a complete page that demonstrates the problem as simply as possible - we'll look into it.
I'm afraid your sample doesn't completely work for me. "pnlContPag" isn't present, so only one of the two ModalPopups can work. pnlDelete is wrapped in "<div style="display:none">" so it's never visible. Removing that display:none wrapper lets me see the delete panel and it seems that hitting either button in it works. Recall that the controls specified by ModalPopup's OkControlID/CancelControlID don't postback anymore, but instead run whatever code's been specified by OnOkScript/OkCancelScript. Might this be the issue?
Yeah, your are right, I have ommited some lines :)
It was really huge!!!!!!

But I'm having the same problem with the 'pnlContPag' and the 'pnlDelete'

hmmm...
It haven't worked.
The greatest problem is that I'm losing the reference to the code-behind events when using the modal panel. I need them to postback so I can delete (in the case of the pnlDelete...) the current record. I already have the functions on the .cs file with the code to delete the record.

HELP MEEEE!

Thanks again for the help!

Jeff
If you want a control in the ModalPopup to postback, don't hook it up as an Ok/Cancel button. It should postback normally and the act of posting back will dismiss the ModalPopup.

Control cpe_ClientState0 of type HiddenField must be placed inside a form tag with runat=s

What should i do ?

Hi,

is that control added dynamically? If so, drop a PlaceHolder control in the page and then add the control to that PlaceHolder.

control cannot be created because Visual Studio Cannot find the Controls type in the Contr

Hi Friends, I have installed Visual Studion 2005 on my machine. After creating an AJAX FutureRelese Web project. I tried to add Future Release Controls to my web page. I am getting the following error "control cannot be created because Visual Studio Cannot find the Controls type in the Control Assembly" Could you please get back to me with the solution for this. Thanks and Regards, Baburaj P V

Pls make sure you have System.Web.Extensions referenced. If Not Add it from the Reference Dialog, it is insalled in the GAC. If you also have the previous version then you have to modify the web.config.


It would be greatful, if I could know how to modify the Web.Conf. I have installed ASPDOTNETFutureRelease on Dot Net Fwk 2.0

Best Regards,

Babz


Try adding another entry for System.web.extensions for AJAX controls and prefix it in the control creation in web forms

control cannot be created because visual studio cannot find the controls type in the contr

Just installed Ajax extensions and ajax control toolkit for Vs2005.All fine.

I can drag drop update panel or script manager.

But if I do so with ajax toolkit controls I get a a error as : "control cannot be created because visual studio cannot find the control's type in the control assembly".

I have downloaded and worked with the toolkit at my home comp and it works all fine. But here at my work its giving me this problem.

I googled up to see any solutions but dint find much help!!

So any help with this would be appreciated!! Thanks!!


Hey guys!!

Anyone for the solution??


Did you remember to register it in the GAC? On your work PC, it may not have done that automagically.


Hey thanks for that.

It did work out.

Strange I have added toolkit on couple of PC's and never saw this error.

Just added the Dll to Gac and the problem is solved on my box.

Thanks.

Continuing problem - "Access is denied" client error

I have struggled with this problem for a couple of months now with no solution yet.

I am migrating an existing web site to a newer user-friendly web using AJAX and the AJAX Toolkit controls. I am using a couple of the tab controls on a couple of pages, including the default page. I am using VB 2005 along with SQL Server 2005. The production server is running IIS 5.1 (and yes, I have installed AJAX and the toolkit on it and yes, the dll files are in the bin directory).

Everything works fine on the development machine, but after copying the files to the production server and then viewing the site in IE (6 or 7) on any machine, there are "Access is Denied" errors when trying to use one of the tab controls.

I have searched the internet and did come across and article about this error, but it pertains to using IFRAME and I am not using any. I have uninstalled and reinstalled IIS on the production server, I have uninstalled and reinstalled both AJAX and the toolkit.

I am at a loss - is there anything that I am overlooking? I would like to have this newer website up and running by June 1, however if there is still these errors, I will have to revert back to the older non-AJAX enabled site.

Thanks for any information.

Anybody?

Here is a thought too and I don't know if this has anything to do with it, but my site is run locally at home using a static IP address. The URL is registered through Yahoo Small Business.

Would that have anything to do with it for any reason?


And to add to it, the error points tohttp://<the ip address>/thewebpage

ContextMenus from PopupExntender without the xml script?

Hello,

A while back I figured out a way to implement "context menus" on top of the built-in Asp:menu control and documented that here:

http://apps.ultravioletconsulting.com/misc/ContextMenus.aspx

This approach uses a hyrbid server/client data-binding technique, but this approach still relied on rendering menu data from the server and relying on the messy HTML table that were output. I was able to drastically reduce the amount of data / javascript passed to the client to that point that it was nothing more than an array embedded in a click handler:

<table style="border:1px solid green"border="0"cellpadding="0"cellspacing="0">

<tr valign="top">
<td>
1: $5 <button value="Do it Now!">Do it Now!</button>
</td>
<td class="MenuCell"
onclick="ContextMenu_Place(event,'Menu1', [1,5])"></td
</tr>
</table>

I tried to use the PopupControl Extender instead to popup a more static block ot HTML / div tags, and it worked fine, except it generates a gigantic amount of XMLScript for each instance. I really need to do nothing more than pass the data values and the location on the screen where the popup should occur. I don't need all the extra Behavior tags, etc.


Any ideas?

Thanks,

Josh

Hi Josh,

The latest release (60914 on 9/15) updated a number of controls to use functionality similar to DynamicPopupate. PopupControl, and others, now have a DynamicContextKey property that may do exactly what you need.

Thanks,
Ted

Thanks Ted,

I ended up writing my own simple ContextMenu_Place function that calls a client-side template/data-binding function to handle this functionality. I am still having one problem though with __doPostBack

Is it possible to manually specify the second parameter in a __doPostBack handler?

I have this code:
<asp:LinkButton runat="server" ID="actTestServerSide"
Text="Test of Server Side Link Button"
CommandName="Action"
CommandArgument="$1"
/>
The rendered code looks like this:

BLOCKEDSCRIPT__doPostBack('ctl00$ctl00$ctlPagePlaceHolder$MyAccountContentPlaceHolder$ctlWonView$actTestServerSide','')

That second parameter is empty though!

Ineed to be able to have code on the _client side_ replace the $1 with avalue of my choice before the actual link gets submitted. The reasonfor this is that I have a GridView with 100 items in it, and I passdown one static block of HTML code as a client-side template for acontext menu that operates on the line item of each GridViewRowinstance. I then have a click handler which does something like:

onclick="ContextMenu_Place(event,'ctlPathGoesHere$blah$blah$blah','ctl00Path$blah$blah',[],['189884','44394743']);
TheContextMenu_Place function copies the template code and then uses thevalues of the second array to replace the placeholders. The firstarray, empty here, specifies the css class name of rows in the menuthat need to be grayed out.

The static block looks like this when rendered to the client side:

 <table id="blah_blah_Container"border="0"cellpadding="0"cellspacing="0"class="ActionsContextMenuContainer">
<tr valign="top">
<td>
<div id="blah$blah">
<div class="actContact"><a title="Contact"href="/Contact.aspx?Item=$1">Contact</a></div>
<div class="actPay"><a title="Pay"href="/Pay.aspx?Item=$1">Pay</a></div>
<div class="actTestServerSide">
<a id="blah$blah$blah"
href="BLOCKED SCRIPT__doPostBack('$blah$blah$blah','')">Test of Server Side Link Button</a>
</div>
</div>
 </td>
</tr>
</table
In the first two cases, the links are to external pages, not POSTBACKS. But in the last case, the action should be POSTBACK, so I need that last line to read:

href="BLOCKED SCRIPT__doPostBack('$blah$blah$blah','$1')">Test of Server Side Link Button</a
This will enable me to use my client side templating function to replace the argument with the actual line item ID.

But, I can't figure out how to get that second parameter of __doPostBack to be non-blank.

Is this feasible? I suppose I could manually replace instances of '') but that seems like a major hack if I can instead get my $1 in there properly.

 
Thanks,
Josh 



Hi Josh,

I'm definitely not an expert on__doPostBack (for that you should probably ask this in thegeneral ASP.NET forums). The only way I know of accessing the optional second event arg is by implementingSystem.Web.UI.IPostBackEventHandler.

Also - Davidblogged about how to get this scenario working withModalPopup and some of the new Toolkit features if you were interested.

Thanks,
Ted

Ted, thank you,

I was able to make a neat little control to accomplish this.


I created one control named ContextMenu inheriting from ASP:Menu.

This allowed me to use <asp:MenuItem> instances instead of hard coding the HTML like I had above.

Next, I overrode the CreateChildControls method to create essentially that same blob of HTML above instead of letting the built in behavior render the HTML.

I added an ASP:Button and an ASP:HiddenField and wrapped them in a DIV with display:none.

Added a Command event to the ContextMenu class of type CommandEventHandler.

Next I made it a convention that if the Target property of the menuItem was set to "POSTBACK", then I would use the Page.ClientScript.GetEventReference(object, argument, registerForEventValidation) method. This actually creates the call to __doPostBack. So, I specified my hidden ASP:Button as the target. In the Value property of the asp:MenuItem, I made it so that "actSomeCommand|$0" would mean that actSomeCommand would be the CommandName, while $0 would be passed down to the client side to allow for the client-side data-binding.

In the href for the anchor tag, I prefixed the call to __doPostBack with a call to document.getElementById('id_of_the_hidden_field_here').value = '$0'. So this allowed my line-item data to be populated just in time for the pop up.

Within a private Command handler for the actual Asp:Button, I read the value of the hidden field -- because I still could not get the real argument to get passed-- then created my own CommandEventArsg and fired that event up to the calling client code.

The end result lets me do this:

<auc:ContextMenu ID="ctlContextMenu" runat="server">
<Items>
<asp:MenuItem
Value="actBuyNow"
ToolTip="Buy this item now!"
Text="Buy Now!"
NavigateUrl="~/Site/ViewItem.aspx?Item=$0#BuyItem"
Target="__self"
/>
<asp:MenuItem
Value="actBid"
ToolTip="Bid on this item"
Text="Bid"
NavigateUrl="~/Site/ViewItem.aspx?Item=$0#PlaceBid"
Target="__self"
/>
</Items>
</auc:ContextMenu
And in my GridView:

<asp:TemplateField HeaderText="Actions" HeaderStyle-CssClass="TextCentered" ItemStyle-CssClass="GridItemActions">
<ItemTemplate>
<auc:ContextMenuPopup
runat="server"
ContentControlContainerID="<%# ctlContextMenu.ClientID %>"
ContentControlID="<%# ctlContextMenu.ContentControlID %>"
id="ctlContextMenuPopup"
/>
</ItemTemplate>
</asp:TemplateField>

-- Note, I'm not so sure I really need both a ContentControlContainerID and ContentControlID on second thought. I could have just had a private convention with my javascript for fetching the actual menu item Divs out of the container, but this works...

Finally, in my code behind:

First, wire up the event handler on the ContextMenu:

ctlContextMenu.Command +=
new CommandEventHandler(ctlContextMenu_Command);

Later, during data binding of my GridView:

ContextMenuPopup menu = e.Row.FindControl("ctlContextMenuPopup")
as ContextMenuPopup;
if (null != menu)
{
menu.DataBind();
}

if (null != menu)
{
string[] lineItemData = new string[2];
lineItemData[0] = item.ItemID.ToString();
lineItemData[1] = item.SellerUserID.ToString();

List<string> hiddenItemIds = new List<string>();

if (0 == item.IsActive())
{
hiddenItemIds.AddRange(new string[] { "actBuyNow", "actBid" });
}

menu.CompleteContextMenu(hiddenItemIds.ToArray(), lineItemData);
}

This call to CompleteContextMenu generates the necessary javascript handler to be added to the container level. It also specifies, depending on the state of the item, which items of the menu should be disabled upon popup.

Last but not least,

protected void ctlContextMenu_Command(object sender, CommandEventArgs e)
{
string action = e.CommandName;
string data = e.CommandArgument as string;

AddFeedback(string.Format("Received command: {0} with argument {1}", action, data));
}

On the client side:

<div class="ContextMenuContainer">
<span id="ctl00_ctl00_ctlPagePlaceHolder_ctlMyView_ctlItems_ctl02_ctlContextMenuPopup_ctlActionsContextMenuLink"
onclick="ContextMenu_Place(event,'ctl00_ctl00_ctlPagePlaceHolder_ctlMyView_ctlContextMenu',
'ctl00_ctl00_ctlPagePlaceHolder_ctlMyView_ctlContextMenu_ctlContextMenuContent',
[],
['189884','44394743'],
this,
);">
Select <img src="../../Controls/ContextMenu_Resources/dwn.gif"align="absmiddle"style="height:27px;width:30px;border-width:0px;"/>
</span>
</div>

Looking back, it was quite a challenge to get this thing working! But, it was fun to write and worth it...

Josh

ContextKey not working in AutoCompleteExtender

My project works fine if I do not useContextKey at all.

If I remove ContextKey from VB code and removeUseContextKey,ContextKey fromHTML it works fine.

Here's my VB code and HTML declaration

Pl let me know what I need to do to make it work.

TIA

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

PublicFunction GetCompletionList(ByVal prefixTextAsString,ByVal countAsInteger,ByVal ContextKeyAsString)AsString()

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

<cc2:AutoCompleteExtenderID="AutoCompleteExtender1"runat="server"

TargetControlID="txtFirstName"ServicePath="AutoComplete.asmx"

ServiceMethod="GetCompletionList"UseContextKey="true"ContextKey="First_Name"MinimumPrefixLength="1"

CompletionInterval="1000"EnableCaching="true"CompletionSetCount="12">

</cc2:AutoCompleteExtender>

What does not work if you use the context key? Does it not return any results? Does it not use the context key? Do you get a javascript error? Have you taken a look at the usage of ContextKey in the Toolkit solution. You should find some under the ToolkitTests project or if you download the code from the Development tree then under Testing.Client project.


Hi MP11,

If you do some modifications on your web.config, we suggest that you should save the web.config without any changes to avoid the cache issues before your debug it. If it doesn't work, please add breakpoints to your webservice to debug it step-by-step.

I hope this help.

Best regards,

Jonathan


Kirti

If I drop ", ByVal ContextKey As String" from web service VB code and drop the "UseContextKey="true" ContextKey="First_Name"" from HTML, AutoCompleteExtender works just fine.

Jonathan,

I have a break point in VB code but it does not break when I use contextkey. It breaks if I do not use ContextKey.

Mahesh


PS I did not make it very clear about what I want to do. I want to call the same web service method for two different textboxes viz. txtFirstName and txtLastName. I want to pass a parameter value txtFirstName or txtLastName via ContextKey.


Hi MP11,

mp11:

PublicFunction GetCompletionList(ByVal prefixTextAsString,ByVal countAsInteger,ByVal ContextKeyAsString)AsString()

Please useByValcontextKeyAsString)AsString() instead ofContextKey. It is recommended that you should save your web.config without any modifications before you debug it if you have done some changes to the WebService.

I hope this help.

Best regards,

Jonathan


Jonathan,

I'm back after a brief vacation.

Your suggestion about contextKey worked.

Thanks a lot.

ContextKey is not a valid attribute of AutoCompleteExtender

So we need to use the ContextKey (and, by extension, UseContextKey) property with our project but it doesn't seem to in the actual control even though I've seen form posts in which people speak of using it. I also can't find any reference to the ContextKey being mothballed anywhere.

What gives? Where's thebeef ContextKey?

Hi,

Do you have the latest version of the Toolkit? Those properties were added pretty recently.

Thanks,
Ted


Yeah, that was the first thing I checked...

Hi,

I'm using 1.0.10618. And I can see Contextkey property is there.

Context.Cache not available intermittently using UpdatePanel

I store some settings used by my application in the Context.Cache. When I postback using an UpdatePanel, sometimes it is available and other times it is simply Nothing as if it doesn't exist. There seems to be no consistent pattern and the code has not changed. It just works sometimes and other times it does not.

Is this a known issue with the ASP.NET Ajax team or is there something I am not aware of that needs to be set or configured to support getting the Context.Cache properly?

Thanks for any help or insight.

Regards,

Don

Hi,

The cache returned by the Context object is actually a static object shared by the whole application. It's not likely to be null.

I suspect that the NullReferenceException is thrown by the Context object, please try using HttpRuntime.Cache to access it rather than Context.Cache.


Another possibility is that the cache is expired.Please trying specifying disableExpiration="true" [ http://msdn2.microsoft.com/en-us/library/ms228248.aspx ].

Hi Raymond - Thanks for the reply and the help. Unfortunately, using the HttpRuntime.Cache instead of Context.Cache produces the same intermittent results. I am convinced this is a problem with ASP.NET Ajax v1.0. I have used the Cache functionality for some time on other projects and have never had an issue like this. Also, this is not a timeout error as I am testing immediately after I fire up the application and as I said, sometimes it works and then for no reason on an Ajax partial page postback it will fail and nothing will be there.

My solution for this is to rely on the Session and so far I have had no issues with that.

Thanks again for your help and if you have any other suggestions, or would like me to post my code, let me know. Thanks!

Don


Hi Don,

Please show me a small, self-sufficient sample.

Thanks.


Hi Raymond - Below are the basic steps I go through:

In my Global.asax:

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

Sub Session_Start(ByVal senderAsObject,ByVal eAs EventArgs)
HttpRuntime.Cache.Insert("MCSApplicationSettings", ApplicationSettingsLoader.GetApplicationSettings(ConfigurationManager.AppSettings("MCSApplicationSettingsURL")))

EndSub

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

This gets populated for each session that fires up.

In my ASPX Page:

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

Private applicationSettingsAs Hashtable =Nothing

PrivateSub Page_Init(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.Init

_applicationSettings = CType(HttpRuntime.Cache.Get("MCSApplicationSettings"), Hashtable)

EndSub

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

Everything works fine until I do a partial postback and try to access the Cache. Sometimes it is there and sometimes it is not.

Thanks,

Don