Showing posts with label sample. Show all posts
Showing posts with label sample. Show all posts

Monday, March 26, 2012

Prevent popupcontrolextender from full postback.

I follow the sample popupcontrol from the samplewebsite package. I spent couple hours trying to figure out where I'm doing wrong: the asp:control, the popupcontrolextender, or the updatepanel. Everytime I click submit in the popup box it does a full postback. The popupcontrolextender's popupcontrolid is using asp:panel. I know the updatepanel inside the asp:panel is working, because I pulled it out from the popupcontrolextender and the asp:panel.

Maybe it is the asp:control I'm using, the asp:hyperlink to execute the popupcontrolextender. But, I need to use something similar to asp:hyperlink.

Here is my markup code:

1<%@dotnet.itags.org. Page Language="vb" AutoEventWireup="false" CodeBehind="TestAjaxControlToolkit.aspx.vb" Inherits="AjaxSandbox.TestAjaxControlToolkit" %>
2<%@dotnet.itags.org. register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4<html xmlns="http://www.w3.org/1999/xhtml" >
5<head runat="server">
6<title>Ajax Control Toolkit</title>
7</head>
8<body>
9<form id="form1" runat="server">
10<asp:scriptmanager id="ScriptManager1" runat="server" />
11<%=DateTime.Now.ToString %>
12<br />
13If the date and time above change, means the whole page postback.
14<hr />
15<h3>PopupControl</h3>
16<asp:label id="lblFirstName" runat="server" text="First Name:" /> <asp:textbox id="txtFirstName" runat="server" /> <asp:hyperlink id="hypFirstNameNote" navigateurl="#" runat="server">[Note]</asp:hyperlink>
17<cc1:popupcontrolextender id="pceFirstName" runat="server" targetcontrolid="hypFirstNameNote" popupcontrolid="pnlNotePopup" position="bottom" />
18<br />
19<br />
20<asp:label id="lblLastName" runat="server" text="Last Name:" /> <asp:textbox id="txtLastName" runat="server" /> <asp:hyperlink id="hypLastNameNote" navigateurl="#" runat="server">[Note]</asp:hyperlink>
21<cc1:popupcontrolextender id="pceLastName" runat="server" targetcontrolid="hypLastNameNote" popupcontrolid="pnlNotePopup" position="bottom" />
22<br />
23<div style="visibility:hidden;position:absolute;">
24<asp:panel id="pnlNotePopup" runat="server">
25<div style="width:320px;padding:0.2em 0.2em;border:1px outset gray;background:white;">
26<asp:updatepanel id="upNotePopup" runat="server">
27<contenttemplate>
28<asp:textbox id="txtNote" runat="server" rows="6" width="98%" textmode="MultiLine" />
29<asp:button id="btnNoteSubmit" runat="server" text="Submit" onclick="btnNoteSubmit_Click" />
30<asp:hiddenfield id="hidNote" runat="server" />
31</contenttemplate>
32</asp:updatepanel>
33</div>
34</asp:panel>
35</div>
36<br />
37<asp:updatepanel id="upOutputSubmit" runat="server">
38<contenttemplate>
39<asp:button id="btnOutputSubmit" runat="server" text="Submit" onclick="btnOutputSubmit_Click" />
40<br />
41<asp:label id="lblOutput" runat="server" />
42</contenttemplate>
43</asp:updatepanel>
44<h3>DropDown</h3>
45</form>
46</body>
47</html>

Here is my vb.net code:

1Public PartialClass TestAjaxControlToolkit
2Inherits System.Web.UI.Page
34Protected Sub btnNoteSubmit_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)
5 hidNote.Value &= HttpUtility.HtmlEncode(DateTime.Now.ToLongTimeString &": " & txtNote.Text &"<br />")
6 txtNote.Text =String.Empty
7End Sub
89 Protected Sub btnOutputSubmit_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)
10 lblOutput.Text ="<br /><strong>Output General:</strong><br />" & txtFirstName.Text &" " & txtLastName.Text &"<br />" &"<strong>Output Note:</strong><br />" & HttpUtility.HtmlDecode(hidNote.Value)
11End Sub
1213End Class

*Bump*

Anybody?


*Bump*

Anybody home?


The sample seems to work fine for me with the 61106 Toolkit release and ASP.NET AJAX Beta 2. Try that configuration, please.

Probably, I found a bug [NewLine in MultiLine TextBox]

Try to run this sample (enter to textbox some lines of text, and then click "Post"):

<%@dotnet.itags.org. Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits=".WebForm1" %><!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></head><body> <form id="form1" runat="server"> <div><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><asp:UpdatePanel ID="updPanel" ChildrenAsTriggers="true" runat="server"><ContentTemplate><asp:TextBox ID="txtTest" runat="server" TextMode="MultiLine" /><asp:Button ID="butTest" runat="server" Text="Post" /><br /><div style="border:solid 1px red; padding:20px;"><%=txtTest.Text.Replace(Environment.NewLine, "<br/>")%></div></ContentTemplate></asp:UpdatePanel> </div> </form></body></html>

I am using a release version of AST.NET AJAX.

What's the bug?

If you enter some lines of text in Firefox into textbox, and then post it to the server via AJAX, newline symbols will be damaged.

In Opera and IE all works fine.


"Firefox" would be the reason I didn't see the error initially. That is a pretty annoying bug.

I'm experiencing this exact same issue ... did you get it resolved?

Cheers!

Saturday, March 24, 2012

Problem Dragging ModalPopupExtender

In the ModalPopupExtender when I drag the popup it always snaps back to the middle.

If I place the JavaScript code that is in the sample page on my page then I am able to drag the popup around the page and it stays where I drop it as expected.

<script type="text/javascript"> // The following snippet works around a problem where FloatingBehavior // doesn't allow drops outside the "content area" of the page - where "content // area" is a little unusual for our sample web pages due to their use of CSS // for layout. function setBodyHeightToContentHeight() { document.body.style.height = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight) + "px"; } setBodyHeightToContentHeight(); $addHandler(window, "resize", setBodyHeightToContentHeight); </script>

The JavaScript says it's just a work around due to how the sample page is structured. But, in my page I'm not using any type of css layout (other than for the ModalPopupExtender background). I just have a HyperLink, Panel for the popup, Panel for the popup handle and ModalPopupExtender.

<%@dotnet.itags.org. Page Language="C#" %><%@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"><script runat="server">protected void ButtonOK_Click(object sender, EventArgs e){Response.Redirect("myModal.aspx");}</script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><title>Untitled Page</title><style type="text/css">/*Modal Popup*/.modalBackground{background-color: #000000;filter: alpha(opacity=30);opacity: 0.3;}</style></head><body><form id="form1" runat="server"><div><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><asp:HyperLink ID="LinkShow" runat="server">Click to show dialog</asp:HyperLink><br /><br /><br /><asp:Panel ID="PanelPopup" runat="server"><asp:Panel ID="PanelPopupHandle" runat="server">This is the popup handle</asp:Panel>This is the content of the popup panel<br /><asp:Button ID="ButtonOK" runat="server" Text="OK" onclick="ButtonOK_Click" /><asp:Button ID="ButtonCancel" runat="server" Text="Cancel" /></asp:Panel><br /><cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" BackgroundCssClass="modalBackground"TargetControlID="LinkShow" CancelControlID="ButtonCancel" Drag="True" PopupControlID="PanelPopup"PopupDragHandleControlID="PanelPopupHandle"></cc1:ModalPopupExtender></div></form></body></html>

Am I missing something or do I need to always place that piece of JavaScript on pages that use the ModalPopupExtender?

this is problem due to not specifying height and width for popup panel
try adding height and width:-

<asp:PanelID="PanelPopup"runat="server"Width="300"Height="300"BorderWidth="1"BackColor="AliceBlue">


Yes, that works. Thank you!


As soon as I click on the dragable header of the ModalPopupExtender popup, the panel moves to the right. It keeps doing this every time I click on it.

I have read every work around on the web to fix this and nothing has worked for me:

1. Added the javascriptsetBodyHeightToContentHeight()

2. Set the Height and Width of the body tag

3. Modified FloatingBahavior.js:

this.onDragEnd =function(canceled) {

canceled =false; <-- added this

4. Set the width and height in the last post.

Nothing has worked for me! Even setting Drag="true" or Drag="false" seems to not work at all.

I could sure use an answer.

Wednesday, March 21, 2012

problem migrate from atlas to ajax

Hi,

I have the folloving problem.

I' ve downloaded sample drag and drop apllication from codeproject.com (http://www.codeproject.com/Ajax/AtlasDragNDrop.asp) and I need to migrate it from atlas to new ajax v1.0beta.

Problem is I didn't find many sample apllictacion in new Ajax and i have problem to rewrite javascript code:

for example:

orginal:

function addFloatingBehavior(ctrl){
var floatingBehavior = new Custom.UI.FloatingBehavior();
floatingBehavior.set_handle(ctrl);
var dragItem = new Sys.UI.Control(ctrl);
dragItem.get_behaviors().add(floatingBehavior);
floatingBehavior.initialize();
}

my try:

function addFloatingBehavior(ctrl){
var floatingBehavior = $create(AjaxControlToolkit.FloatingBehavior,{'handle' : ctrl}, ctrl );
floatingBehavior.initialize();

}

it doesnt work

next scriptmanager in atlas has something like
<atlas:ScriptReference ScriptName="AtlasUIDragDrop" />

in ajax i cann't find replacement

In simple, my problem is add a floatingbehavior to DIV

(DragPanelExtender is not a solution for me)

Thanx for help

Any suggestion?

Please can anybody help me to write simple page with one button. If i click this button - new element (div) is added to page, and this div have to have floatingbehaior.

If I click button again, next div is created and so on...

It have to be in ajax v1.0 beta ...

If you want to see the same apllication in atlas please look at :http://www.codeproject.com/Ajax/AtlasDragNDrop.asp

It′s very urgent. Please help

Thanks Mayo.


I don't have a full answer, but I can tell you the drag and drop I believe is now in the CTP PreviewDragDrop.js file. with the floating behavior being Sys.Preview.UI.FloatingBehavior.