Showing posts with label click. Show all posts
Showing posts with label click. Show all posts

Wednesday, March 28, 2012

postback inside modalpopupextender

I want to show a modalpopupextender that contains: a textbox ,A button, gridview, ok button , close button: when the user click on A button the gridview must be populated , I need this behavior inside the modalpopupextender but it seems like modalpopupextender does not support any control that make a postback, How can I manage this??

Best Regards

Joseph

I already have done this what you need to do is,

let say. btnSearch popups your ModalpopupExtender,

when you click in side the control do one thing only in the code behind, of that click event either grid pageindexchange, sortiung, any button click in the last. that is.

ModalPopupExtender1.Show()

it will keep showing the popup until you click close button or call a method.

ModalPopupExtender1.Hide()

It is trial and tested, even I have done more than this in my application.

IF THIS MAKES ANSWER PLEASE CLICK ANSWER ON MY POSTING

Regards,


Hi Killerjocker,

My understanding of your issue is that you want to show some controls include the GridView and generate(update) the content inside it when click on the Button which is associated with the ModalPopupExtender. If I have misunderstood, please feel free to let me know.

In my opnion, I think the easiest way for your situation is adding a UpdatePanel into the Panel which is associated with the ModalPopupExtender and the GridView is put inside the added UpdatePanel. When user click on the Button, the UpdatePanel will be refreshed by sending a asynchronous post and then the shows the ModalPopupExtender. Here is a sample:

<%@. Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server"
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<style>
.modalBackground {
background-color:Gray;
filter:alpha(opacity=70);
opacity:0.7;
}

.modalPopup {
background-color:#FFD9D5;
border-width:3px;
border-style:solid;
border-color:Gray;
padding:3px;
width:250px;
}
</style>

</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Button ID="Button2" runat="server" Text="Button" Enabled="false" style="display:none"/>
<asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" Height="50px" Width="235px" style="display:none" DefaultButton="Button4">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<%=DateTime.Now.ToString()%>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button ID="Button1" runat="server" Text="Cancel" />
<asp:Button ID="Button4" runat="server" Text="Button" />
</asp:Panel>

<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="Button2" PopupControlID="Panel1" CancelControlID="Button1" DropShadow="true" BackgroundCssClass="modalBackground">
</ajaxToolkit:ModalPopupExtender>
<input id="Button3" type="button" value="Click Me" onclick="showModalPopup()"/>
<script type="text/javascript" language="javascript">
function showModalPopup(){
__doPostBack('<%=UpdatePanel1.UniqueID%>','');
$find("<%= this.ModalPopupExtender1.ClientID%>").show();
}
</script>
</form>
</body>
</html>

I hope this help.

Best regards,

Jonathan

Postback Multitask progress bar (ajax)

hello

I have a asp.net page that takes several actions uppon a button click.

Suppose this page triggers 3 functions on that button click: (THIS IS JUST AN EXAMPLE)
1) Saves data to local data base
2) Export data do internet data base
3) send emails to 50 users reporting this update

What I want to do is show the user wich action the server is performing at the moment.
basically, it should show (on a Modal PopUP, i figure) all the 3 steps taken.
1) ...saving data...
2) ...exporting data ...
3) ... notifying users ...

does anyone have a solution for this?

thanks

Checkout this threadhttp://forums.asp.net/t/1133013.aspx

postback when button click in firefox

Hi all,

can anybody help me out ?

I have a button and i write ...

<button id=

"clipButton">

<behaviors>

<clickBehavior>

<click>

<invokeMethod method=

"show" target="clipPopup" />

</click>

</clickBehavior>

</behaviors>

</button>

so button is clicked a div is popup ed. Its working fine in IE but in Firefox when i click on button postback occurs...i cud nt understand why its happening...please help me.

Thanks and Regards

Riyaz

Sorry folks, actuaaly i forgot to mention that im using dataNavigator

<dataNavigator id=

"pageNavigator" dataView="dataView"/>

and dataView

<dataView id=

"dataView" pageSize="7">

<bindings>

<binding dataContext=

"ClipartDS" dataPath="data" property="data" />

</bindings>

</dataView>

to display the filtered data from the dataView in the listView. I thought it'ld be a couse of the problem...plz comment on my problem.

Regards

Riyaz


hello.

can you post a small page with the hml + xml-script that demonstrates the problem you're having?


actually when i click button a div is popup with certain cliparts and when i click any clipart popup disappears and selected clipart is shown right hand side.

The HTML part is below:

<

br/>

Click this button to choose a clipart image

<br/><buttonid="clipButton">

ClipArt

</button><br/><divid="ClipArt"></div>

<

divid="PopColors"style="display:none; position: absolute; border-right: blue thin dotted; border-top: blue thin dotted; border-left: blue thin dotted; border-bottom: blue thin dotted;"></div>

<

divid="clipartImageRight"style="left: 500px; position: absolute; top: 290px; "><imgid="clipartImage"alt="Clip"src=""height="35"width="35"/></div>

<

divid="clipTemplate"><spanid="clipItemTemplateParent"><spanid="clipItemTemplate"><span><ahref="javascript:;"><imgid="clip"height="50px"width="50px"alt=""src=""/></a></span></span></span><divid="pageNavigator"><inputtype="button"id="firstPageButton"value="<<"/><inputtype="button"id="previousPageButton"value="<"/><inputtype="button"id="nextPageButton"value=">"/><inputtype="button"id="lastPageButton"value=">>"/> <aid="closePopUP"href="javascript:;"style=" color:Red; left: 350px; position: absolute;">close</a></div></div>

The XML markup is here :

<button id=

"clipButton">

<behaviors>

<clickBehavior>

<click>

<invokeMethod method=

"show" target="clipPopup" />

</click>

</clickBehavior>

</behaviors>

</button>

<dataNavigator id=

"pageNavigator" dataView="dataView"/>

<button id=

"firstPageButton" parent="pageNavigator" command="firstPage">

</button>

<button id=

"previousPageButton" parent="pageNavigator" command="previousPage">

<bindings>

<binding property=

"enabled" dataPath="hasPreviousPage"/>

</bindings>

</button>

<button id=

"nextPageButton" parent="pageNavigator" command="nextPage">

<bindings>

<binding property=

"enabled" dataPath="hasNextPage"/>

</bindings>

</button>

<button id=

"lastPageButton" parent="pageNavigator" command="lastPage">

</button>

<dataView id=

"dataView" pageSize="7">

<bindings>

<binding dataContext=

"ClipartDS" dataPath="data" property="data" />

</bindings>

</dataView>

<listView id=

"ClipArt" itemTemplateParentElementId="clipItemTemplateParent"

tabIndex=

"0" dataIndex="-1" >

<bindings>

<binding dataContext=

"dataView" dataPath="filteredData" property="data"/>

</bindings>

<behaviors>

<popupBehavior id=

"clipPopup" parentElement="clipButton" positioningMode="BottomRight" />

<clickBehavior>

<click>

<invokeMethod method=

"hide" target="clipPopup" />

<invokeMethod method=

"UpdateImage" target="XMPData" />

</click>

</clickBehavior>

</behaviors>

<layoutTemplate>

<template layoutElement=

"clipTemplate"/>

</layoutTemplate>

<itemTemplate>

<template layoutElement=

"clipItemTemplate">

<image id=

"clip">

<bindings>

<binding property=

"imageURL" dataPath="Image"/>

</bindings>

</image>

</template>

</itemTemplate>

</listView>

<image id=

"clipartImage">

<bindings>

<binding property=

"imageURL" dataContext="ClipArt" dataPath="dataItem.Image"/>

</bindings>

</image>

Thanks and Regards

Riyaz

Postback? how?

in Ajax, how is it possible to do a postback to the server? So for example, i have a modalpopupdialog, and when i click the ok button in it, i want it to postback to the server to process the request or whatever.

how is this done? Currently I have a scriptmanager on the aspx page, and the User control for the modaldialog - now what?

I've noticed something.

If I don't add this custom user control containing ajax in a webpage, then anything on that webpage, the links and button clicks work fine. However if I add this user control with ajax, the button post backs do not fire at all. This is wierd and no idea why. I think it maybe to do with the scriptmanager or the modalpopupextender but not sure

what would the reason be for the click events to the server not being able to fire when we add this user control?


I'm not sure why postbacks don't work with the modal popup, possibley because it was intended to be used with javascript to customise the page?

In any case, you can use the OnOkScript and OnCancelScript properties of the modalpopupextender to fire a postback. You just need to add this line of javascript as the script that is fired when one of those buttons is pressed:

__doPostBack(TargetControl, Argument);


Replace TargetControl with the control id that triggered your postback (if you want a pass the server a different control id you can too) and replace Argument with any argument you want to pass to the server.

Then, in the Page_Load of your page add these lines:

string controlid = Request.Params.Get("__EVENTTARGET");
string argument = Request.Params.Get("__EVENTARGUMENT");

This will allow you to read the arguments you have passed the server, from here you can trigger a function or event handler.



I actually did that before also but made no difference.

Basically.....

If I have a form and place a simple button on it, double click it to make the click event and do something like Response.Write("I was clicked");, it will work fine.

BUT as soon as I add the modalpopupextender, or even infact, add the assembly reference in the aspx file for the ajaxtoolkit, then when i click that button again - nothing happens. no post back is happening. nothing is firing back at all - the page stays the exact same.


any ideas? I'm stuck. I just created a new ajax enabled project on my main home computer, and the same thing happens - when you insert the modalpopupextender, set all the properties etc... it doesnt fire anything (it shows the control of course) but when you take out that control and press say, the button (which is what the OkControlID property is set to in the ajax control), it works and fires the click event.
looks like there seems to be a problem when using base master templates!! How is it possible to use the Base master templates and making ajax do the postback (of the modalpopupextender)

Works great for me – the code…

<asp:LinkButtonID="btnUpload"BackColor="ButtonFace"Font-Size="11px"Font-Underline="false" ForeColor="Black" CssClass="CenterText"BorderStyle="Outset"BorderWidth="1px"

Text="Upload New Photo"runat="server"Width="100px"Visible='<%#IsAdmin%>'>

</asp:LinkButton>

<asp:PanelID="pnlUpload"runat="server" CssClass="modalPopup"style="display:none">

<asp:LabelID="Label5"Font-Size="11px"Font-Bold="true"runat="server"Text="Upload Photo"/>

<asp:LabelID="ErrorLabel"runat="server"Text=""/>

<table>

<tr>

<tdclass="formlabel"align="right">File:</td>

<td><asp:FileUploadID="FileUpload1"runat="server</td>

</tr>

<tr>

<tdclass="formlabel"align="right">Image title:</td>

<td><asp:TextBoxID="imgTitle"runat="server"CssClass="txtfield"/> </td>

</tr>

</table>

<br/>

<tablestyle="margin-left:auto; margin-right:auto;">

<tr>

<tdstyle="width:100px;"align="left">

<asp:ButtonID="btnUploadImg"runat="server"Text="Upload"OnClick="UploadFile_Click"/>

</td>

<tdstyle="width:100px;"align="right">

<asp:ButtonID="btnClose"runat="server"Text="Close"/>

</td>

</tr>

</table>

<br/>

</asp:Panel>

<ajaxToolkit:ModalPopupExtenderID="modalPopup"runat="server"

TargetControlID="btnUpload"

PopupControlID="pnlUpload"

BackgroundCssClass="modalBackground"

DropShadow="true"

CancelControlID="btnClose"/>

Code behind in vb…

ProtectedSub UploadFile_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)

If FileUpload1.HasFile =TrueAnd IsAdminThen

Dim imageidAsInteger

Dim albumidAsInteger

Dim oAsObject = Request.QueryString("AlbumID")

IfNot oIsNothingThen

albumid =CInt(o)

EndIf

imageid = ImageUtils.uploadImage(imgTitle.Text, albumid, FileUpload1.FileContent)

DataList2.DataBind()

DataList2.SelectedIndex = DataList2.Items.Count - 1

FormView2.DataBind()

FormView2.PageIndex = FormView2.PageCount - 1

ErrorLabel.Text =""

Else

ErrorLabel.Text ="<p>Please select a file to upload<p>"

EndIf

EndSub


yeh it doesnt work. I'm wonder if its to do with the fact that base/master pages are being used, as well as several user controls being placed on an aspx page?
Was anybody ever able to resolve this I have the exact same problem, only controls within a gridveiw fire their events...

I don't think it has anything to do with base pages or master pages. The project I'm working on uses a custom base page, inherits from a master page, and runs more than one user control. The modal popup seems to work just fine. One thing worth considering is building an AJAX Control Toolkit website. You'll find the option if you ran the .vsi installer. It can be informative to look at the reference structure and the web.config after creating a temporary site from that template. Good luck!

Keith


Would you mind posting the markup of your ModalPopup that has working controls?
I finally found the cause of this problem.Smile After going through each control I discovered that when I removed the RequiredFieldValidators from the page, the click events fired. So I put them back and then set causesvalidation = false for the button and again the click event fired. This must be a bug with the extender. So basically you have to disable validation on any control in the modal pupup window.

interesting. ill see if we have this (cant right now) however currently the way it stands, it still does not work. I'm able to do it on a simple aspx page (which does not use a master page) but when using a master page, it does not work.

how do we get it to work with validation, should there be validation in our solution/project?


nope - we dont have any requiredFieldValidators on the pages we are using the ajax control on. - still stuck

Monday, March 26, 2012

prevent repeat animation (animationextender)

Hey guys. I have a textbox which will expand when I click it. However, once expanded it's still obviously active and it will replay the animation when I click it again. How can I make the textbox expand (like the example below) when clicked, but then disable further animations of it? I obviously cant disable the textbox. I was thinking a conditionanimation would work but Im not that great with javascript.
<ajaxToolkit:AnimationExtender id="Ani" runat="server" TargetControlID="TextBox1"> <Animations> <OnClick> <Resize width="400px" duration="0.3" fps="10" /> </OnClick> </Animations></ajaxToolkit:AnimationExtender><asp:TextBox ID="TextBox1" Width="200px" TextMode="MultiLine" Rows="6" runat="server" />
Thanks /J

Hi,

Yeah , a conditional animation would be the way to go about this .

Try this Mark-Up ..

<

scriptlanguage="javascript">var expandCount = 1;var expandMaxCount = 1;

function ShouldIExpand()

{

var shouldExpand =false;

if ( expandCount <= expandMaxCount )

shouldExpand =

true;

expandCount++;

return shouldExpand ;

}

</script>

<OnClick>

<ConditionConditionScript="ShouldIExpand()">

<Resize width="400px" duration="0.3" fps="10" /></Condition> </OnClick>

Hope this helps.

If it resolves the issue , please mark my reply as the answer


exactly what i had in mind, it works! ThanksYes

Print Problem With Updatepanel

HI,

Iam facing problem with update panel.I has a reportviewer and a updatepanel.Updatepanel consists of Reportviewer.Whenever i click on Print Option of Reportviewer,Postback ocurs But no print dialog appears.(So no print).How to Print report when it is is in updatepanel.

When i remove updatepanel Print wrks .But when i keep it in updatepanel NO PRINT ocurs

Plz help ...It is Very urgent

With regards,

Mahender

Any chance you can post the code?
<asp:UpdatePanelID="ReportViewerUpdatePanel"runat="server"UpdateMode="Conditional "ChildrenAsTriggers="true"><ContentTemplate><asp:UpdateProgressID="ReportViewerUpdateProgress"runat="server"><ProgressTemplate><divstyle="display:block; "><center>

Loading ...

<imgalt=""src="Images/Updatepanel/loading.gif"/></center></div></ProgressTemplate></asp:UpdateProgress>

<rsweb:ReportViewerID="ReportViewer1"runat="server"BackColor="WhiteSmoke"ProcessingMode="Remote"Height="100%"ShowBackButton="true"ShowFindControls="false"DocumentMapWidth="50%"ShowParameterPrompts="false"ShowRefreshButton="true"ShowReportBody="false"ShowPromptAreaButton="true"ShowToolBar="true"ShowExportControls="true"ShowZoomControl="false"Width="100%"EnableTheming="true"ShowCredentialPrompts="true"DocumentMapCollapsed="true"LinkActiveColor="Black"LinkActiveHoverColor="Chocolate"LinkDisabledColor="Gray"ExportContentDisposition="AlwaysInline"EnableViewState="true"ShowPrintButton="true"><ServerReportReportServerUrl="http://localhost/ReportServer$SQL"/></rsweb:ReportViewer>

</ContentTemplate><Triggers><asp:AsyncPostBackTriggerControlID="DropdownMenuLinkButton"EventName="Click"/>

</Triggers>

</asp:UpdatePanel>

Incode behind of One event.In my case Buttonclick

this is Code

ReportViewer1.ProcessingMode =

ProcessingMode.Remote;Uri u =newUri("http://localhost/ReportServer$SQL");

ReportViewer1.ServerReport.ReportServerUrl = u;

ReportViewer1.ServerReport.ReportPath =

"/thad/Report1";

ReportViewer1.AsyncRendering =

true;

ReportViewer1.ShowBackButton =

true;

ReportViewer1.ShowFindControls =

true;

ReportViewer1.ShowRefreshButton =

true;

ReportViewer1.ShowPrintButton =

true;

ReportViewer1.ShowReportBody =

true;

ReportViewer1.ShowPromptAreaButton =

true;

ReportViewer1.ShowToolBar =

true;// ReportViewer1.ShowExportControls = true;

ReportViewer1.ShowZoomControl =

true;

ReportViewer1.ToolTip =

"Report Viewer";

ReportViewer1.Width =

Unit.Percentage(100);

ReportViewer1.Height =

Unit.Percentage(100);//ReportViewer1.EnableTheming = true;

ReportViewer1.ShowCredentialPrompts =

true;

ReportViewer1.LinkActiveColor = System.Drawing.

Color.Black;

ReportViewer1.LinkActiveHoverColor = System.Drawing.

Color.Chocolate;

ReportViewer1.LinkDisabledColor = System.Drawing.

Color.Gray;

ReportViewer1.ShowPrintButton =

true;
<asp:UpdatePanelID="ReportViewerUpdatePanel"runat="server"UpdateMode="Conditional "ChildrenAsTriggers="true"><ContentTemplate><asp:UpdateProgressID="ReportViewerUpdateProgress"runat="server"><ProgressTemplate><divstyle="display:block; "><center>

Loading ...

<imgalt=""src="Images/Updatepanel/loading.gif"/></center></div></ProgressTemplate></asp:UpdateProgress>

<rsweb:ReportViewerID="ReportViewer1"runat="server"BackColor="WhiteSmoke"ProcessingMode="Remote"Height="100%"ShowBackButton="true"ShowFindControls="false"DocumentMapWidth="50%"ShowParameterPrompts="false"ShowRefreshButton="true"ShowReportBody="false"ShowPromptAreaButton="true"ShowToolBar="true"ShowExportControls="true"ShowZoomControl="false"Width="100%"EnableTheming="true"ShowCredentialPrompts="true"DocumentMapCollapsed="true"LinkActiveColor="Black"LinkActiveHoverColor="Chocolate"LinkDisabledColor="Gray"ExportContentDisposition="AlwaysInline"EnableViewState="true"ShowPrintButton="true"><ServerReportReportServerUrl="http://localhost/ReportServer$SQL"/></rsweb:ReportViewer>

</ContentTemplate><Triggers><asp:AsyncPostBackTriggerControlID="DropdownMenuLinkButton"EventName="Click"/>

</Triggers>

</asp:UpdatePanel>

Incode behind of One event.In my case Buttonclick

this is Code

ReportViewer1.ProcessingMode =

ProcessingMode.Remote;Uri u =newUri("http://localhost/ReportServer$SQL");

ReportViewer1.ServerReport.ReportServerUrl = u;

ReportViewer1.ServerReport.ReportPath =

"/thad/Report1";

ReportViewer1.AsyncRendering =

true;

ReportViewer1.ShowBackButton =

true;

ReportViewer1.ShowFindControls =

true;

ReportViewer1.ShowRefreshButton =

true;

ReportViewer1.ShowPrintButton =

true;

ReportViewer1.ShowReportBody =

true;

ReportViewer1.ShowPromptAreaButton =

true;

ReportViewer1.ShowToolBar =

true;// ReportViewer1.ShowExportControls = true;

ReportViewer1.ShowZoomControl =

true;

ReportViewer1.ToolTip =

"Report Viewer";

ReportViewer1.Width =

Unit.Percentage(100);

ReportViewer1.Height =

Unit.Percentage(100);//ReportViewer1.EnableTheming = true;

ReportViewer1.ShowCredentialPrompts =

true;

ReportViewer1.LinkActiveColor = System.Drawing.

Color.Black;

ReportViewer1.LinkActiveHoverColor = System.Drawing.

Color.Chocolate;

ReportViewer1.LinkDisabledColor = System.Drawing.

Color.Gray;

ReportViewer1.ShowPrintButton =

true;
<asp:UpdatePanelID="ReportViewerUpdatePanel"runat="server"UpdateMode="Conditional "ChildrenAsTriggers="true"><ContentTemplate><asp:UpdateProgressID="ReportViewerUpdateProgress"runat="server"><ProgressTemplate><divstyle="display:block; "><center>

Loading ...

<imgalt=""src="Images/Updatepanel/loading.gif"/></center></div></ProgressTemplate></asp:UpdateProgress>

<rsweb:ReportViewerID="ReportViewer1"runat="server"BackColor="WhiteSmoke"ProcessingMode="Remote"Height="100%"ShowBackButton="true"ShowFindControls="false"DocumentMapWidth="50%"ShowParameterPrompts="false"ShowRefreshButton="true"ShowReportBody="false"ShowPromptAreaButton="true"ShowToolBar="true"ShowExportControls="true"ShowZoomControl="false"Width="100%"EnableTheming="true"ShowCredentialPrompts="true"DocumentMapCollapsed="true"LinkActiveColor="Black"LinkActiveHoverColor="Chocolate"LinkDisabledColor="Gray"ExportContentDisposition="AlwaysInline"EnableViewState="true"ShowPrintButton="true"><ServerReportReportServerUrl="http://localhost/ReportServer$SQL"/></rsweb:ReportViewer>

</ContentTemplate><Triggers><asp:AsyncPostBackTriggerControlID="DropdownMenuLinkButton"EventName="Click"/>

</Triggers>

</asp:UpdatePanel>

Incode behind of One event.In my case Buttonclick

this is Code

ReportViewer1.ProcessingMode =

ProcessingMode.Remote;Uri u =newUri("http://localhost/ReportServer$SQL");

ReportViewer1.ServerReport.ReportServerUrl = u;

ReportViewer1.ServerReport.ReportPath =

"/thad/Report1";

ReportViewer1.AsyncRendering =

true;

ReportViewer1.ShowBackButton =

true;

ReportViewer1.ShowFindControls =

true;

ReportViewer1.ShowRefreshButton =

true;

ReportViewer1.ShowPrintButton =

true;

ReportViewer1.ShowReportBody =

true;

ReportViewer1.ShowPromptAreaButton =

true;

ReportViewer1.ShowToolBar =

true;// ReportViewer1.ShowExportControls = true;

ReportViewer1.ShowZoomControl =

true;

ReportViewer1.ToolTip =

"Report Viewer";

ReportViewer1.Width =

Unit.Percentage(100);

ReportViewer1.Height =

Unit.Percentage(100);//ReportViewer1.EnableTheming = true;

ReportViewer1.ShowCredentialPrompts =

true;

ReportViewer1.LinkActiveColor = System.Drawing.

Color.Black;

ReportViewer1.LinkActiveHoverColor = System.Drawing.

Color.Chocolate;

ReportViewer1.LinkDisabledColor = System.Drawing.

Color.Gray;

ReportViewer1.ShowPrintButton =

true;

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!

Wednesday, March 21, 2012

Problem in ListBox double click in UpdatePanel

Hi,

I have a problem in add ListBox double click in UpdatePanel. Now, my code works well.(It is the solution online) But when I put the ListBox in UpdatePanel, it also refresh the whole page, not AsyncPostBack...The dblclick is in Javascript, I don't how can it also work fine with AJAX. Thanks!

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %
<!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>
<script language="javascript">
function ListBox1_DoubleClick() {
/* we will change value of this hidden field so

that in
page load event we can identify event.
*/
document.forms[0].ListBox1Hidden.value = "doubleclicked";
document.forms[0].submit();
}
</script>
</head>
<body>
<form id="Form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div>Double click on Listbox
<br />
<asp:ListBox id="ListBox1"
ondblclick="ListBox1_DoubleClick()" runat="server">
<asp:ListItem Value="1">One</asp:ListItem>
<asp:ListItem Value="2">Two</asp:ListItem>
<asp:ListItem Value="3">Three</asp:ListItem>
<asp:ListItem Value="4">Four</asp:ListItem>
</asp:ListBox>
<input type="hidden" name="ListBox1Hidden" />
</div>
<div>click on button
<br />
<asp:Button id="Button1" onclick="Button1_Click"
runat="server" Text="Button"/>
</div>
</ContentTemplate>
</asp:UpdatePanel>


</form>
</body>
</html>

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;

public partial class test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(Request.Params["ListBox1Hidden"] != null
&& (string)Request.Params["ListBox1Hidden"] == "doubleclicked") {
//This means It was double click
Response.Write("Double Click was fired selected item is "
+ ListBox1.SelectedItem.Text);
}

}
protected void Button1_Click(object sender, EventArgs e)
{

}
}

I think you should enablepartialrendering property of the ScriptManager.

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" EnablePageMethods="true">

Still not working.......any another idea? Thanks

codeasp:

I think you should enablepartialrendering property of the ScriptManager.

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" EnablePageMethods="true">


Instead of calling submit on the form, try __doPostBack('<%= UpdatePanel1.ClientID %>', '');


Thank you so much! It works now.

Problem in redirection

I have a problem plz help me to sort out it

i am displaying an alert message by java script on page event.

now if user click on the "ok" button of alert then user should navigate to other page other wise not.

if i place Response.Redirect after

"ScriptManager.RegisterClientScriptBlock(this,this.GetType(),"myScript","alert(\"Your registration has been submitted and is waiting for approval from administrator. After approval/denial you will be notified at the provided email address.\");",true);"

it does not show the alert

what should i do to resolve it

help me

try this..

in html

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

<headrunat="server">

<title>Untitled Page</title>

<scriptlanguage="javascript"type="text/javascript">

function showmsgbox()

{

alert("hi");

}

</script>

</head>

<body>

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

<div>

<asp:ButtonID="Button4"runat="server"OnClick="Button4_Click"Text="Button"OnClientClick="showmsgbox()"/></div></form>

</body>

</html>

and in code behind..

protectedvoid Button4_Click(object sender,EventArgs e)

{

Response.Redirect("~/Default8.aspx");

}

problem in serverside validation

hi to all

i have few text box and button in updatepanel . Now i want to do asynchronously postback on button click and for that

i have did my all validation on serverside as follow

CS code

1protected void btnSubmit_Click(object sender, ImageClickEventArgs e)
2 {
3
45try6 {
7if (cmbAdvertisementType.SelectedValue =="0")
8 {
9throw new Exception("You must select a Advertisement Style.");
10 }
1112if (cmbKiosk.SelectedValue =="0")
13 {
14throw new Exception("You must select a Server.");
15 }
1617if (string.IsNullOrEmpty(txtFromDate.Text))
18 {
19throw new Exception("You must supply a Start Date.");
20 }
2122if (string.IsNullOrEmpty(txtToDate.Text))
23 {
24throw new Exception("You must supply an EndDate.");
25 }
2627
2829 System.Threading.Thread.Sleep(4000);
30 DataTable parameterTable = objdt.GetTable();
31 parameterTable.Rows.Add(objdt.CreateRow("@dotnet.itags.org.StarDate", SqlDbType.DateTime, 30, Convert.ToDateTime(txtFromDate.Text, format), ParameterDirection.Input));
32 parameterTable.Rows.Add(objdt.CreateRow("@dotnet.itags.org.EndDate", SqlDbType.DateTime, 30, Convert.ToDateTime(txtToDate.Text, format), ParameterDirection.Input));
33 parameterTable.Rows.Add(objdt.CreateRow("@dotnet.itags.org.ServerId", SqlDbType.Int, 4, Convert.ToInt32(cmbKiosk.SelectedValue), ParameterDirection.Input));
34 parameterTable.Rows.Add(objdt.CreateRow("@dotnet.itags.org.AdvertiseId", SqlDbType.Int, 4, Convert.ToInt32(cmbAdvertisementType.SelectedValue), ParameterDirection.Input));
35 parameterTable.Rows.Add(objdt.CreateRow("@dotnet.itags.org.Mode", SqlDbType.VarChar, 10,"Dataset", ParameterDirection.Input));
36 ds = objDB.GetDSByProcedure("SP_CheckAvailibily", parameterTable);
37 parameterTable.Rows.Clear();
38 gvSlotAvailibily.DataSource = ds;
39 gvSlotAvailibily.DataBind();
40 AccordionView.SelectedIndex = 1;
41 UpdatePanel2.UpdateMode = System.Web.UI.UpdatePanelUpdateMode.Always;
42 UpdatePanel2.ChildrenAsTriggers =true;
43 }
44catch (Exception ex)
45 {
4647 sendPopupMessage(ex.Message);
48 }
49
50 }
5152
5354private void sendPopupMessage(string Message)
55 {
56 ScriptManager.RegisterStartupScript(this,this.GetType(),"key","<script language='Javascript'> alert('" + Message +"'); </script>",false);
57 }

aspx code

1<%@dotnet.itags.org. Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="AdvertiseBook.aspx.cs" Inherits="AdvertiseBook" Title="Advertisement Booking" %>2<%@dotnet.itags.org. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit"%>3<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">4<aspajax:ScriptManager ID="ScriptManager2" EnablePageMethods="True" EnablePartialRendering="true" EnableScriptLocalization="true" runat="server">5 <Scripts>6 <aspajax:ScriptReference Path="AdvertiseBook.js" />78 </Scripts>910 <Services>11 <aspajax:ServiceReference Path="WebService.asmx" />12 </Services>1314 </aspajax:ScriptManager>1516 <div id="lmenucontainer">17 <div class="menuitem" id="m1" name="m1">18 <asp:LinkButton runat="server" Text="Tabular View" ID="lnkView" onmouseover="lmenuover(m1.id);" onmouseout="lmenuout(m1.id);" OnClick="lnkView_Click"></asp:LinkButton>19 </div>20 <div class="menuitem" id="m2" name="m2">21 <asp:LinkButton runat="server" Text="Add New Agency" ID="lnkaddAgency" onmouseover="lmenuover(m2.id);" onmouseout="lmenuout(m2.id);" OnClick="lnkaddAgency_Click"></asp:LinkButton>22 </div>23 <div id="lm5" onmouseover="lmenuover('lm5');" class="menuitem bottomborder" onmouseout="lmenuout('lm5');" name="lm5">24 <asp:LinkButton id="lnkNewAd" onmouseover="lmenuover('lm5');" onmouseout="lmenuout('lm5');" runat="server" Text="New Advertisement" OnClick="lnkNewAd_Click"></asp:LinkButton>25 </div>26 </div><!-- lmenucontainer closing -->27 <aspajax:UpdatePanel ID="UpdatePanel2" UpdateMode="Conditional" ChildrenAsTriggers="False" runat="server">28 <ContentTemplate>2930 <div id="disparea" >31 <asp:Panel ID="pnlTableView" runat="server" Visible="false">32 <ajaxToolkit:Accordion ID="AccordionView" runat="server" SelectedIndex="0"33 HeaderCssClass="accordionHeader" HeaderSelectedCssClass="accordionHeaderSelected"34 ContentCssClass="accordionContent" FadeTransitions="false" FramesPerSecond="40"35 TransitionDuration="250" AutoSize="None" RequireOpenedPane="false" SuppressHeaderPostbacks="true">36 <Panes>37 <ajaxToolkit:AccordionPane ID="AccordionPane5" runat="server">38 <Header><a href="http://links.10026.com/?link=" class="accordionLink">Check Availibility of Slot</a></Header>39 <Content>40 <table>41 <tr>42 <td>43 <asp:Label ID="lblAdvertisementType" runat="server" Text="Advertisement Type" ></asp:Label>44 </td>45 <td>46 <asp:DropDownList ID="cmbAdvertisementType" runat="server" OnLoad="cmbAdvertisementType_Load">47 </asp:DropDownList>48 </td>49 </tr>50 <tr>51 <td>52 <asp:Label ID="lblKiosk" runat="server" Text="Kiosk Name" ></asp:Label>53 </td>54 <td>55 <asp:DropDownList ID="cmbKiosk" CssClass="cmbborder" runat="server" OnLoad="cmbKiosk_Load" ></asp:DropDownList>56 </td>57 </tr>58 <tr>59 <td >60 <asp:Label ID="lblFrom" runat="server" Text="From" ></asp:Label>   61 </td><td>62 <asp:TextBox ID="txtFromDate" EnableViewState="true" runat="server"></asp:TextBox>63 <asp:Image ID="imgFromDate" ImageUrl="~/images/Calendar_scheduleHS.png" runat="server" />64 <ajaxToolkit:CalendarExtender ID="CalendarExtender1" Format="dd/MM/yyyy" Animated="true"65 PopupButtonID="imgFromDate" TargetControlID="txtFromDate" EnableViewState="true" runat="server">66 </ajaxToolkit:CalendarExtender>67 </td></tr>68 <tr><td>69 <asp:Label ID="lblTo" runat="server" Text="To" ></asp:Label>70 </td><td>71 <asp:TextBox ID="txtToDate" EnableViewState="true" runat="server"></asp:TextBox>72 <asp:Image ID="imgToDate" ImageUrl="~/images/Calendar_scheduleHS.png" runat="server" />73 <ajaxToolkit:CalendarExtender ID="CalendarExtender2" Format="dd/MM/yyyy" Animated="true"74 PopupButtonID="imgToDate" TargetControlID="txtToDate" EnableViewState="true" runat="server">75 </ajaxToolkit:CalendarExtender>76 </td>77 </tr>78 <tr>79 <td colspan="2" align="center">80 <asp:ImageButton ImageUrl="~/images/submit.gif" ID="btnSubmit" runat="server" OnClientClick="CheckDateValidation();" OnClick="btnSubmit_Click" />8182 </td>83 </tr>848586 </table>87 </Content>88 </ajaxToolkit:AccordionPane>89 <ajaxToolkit:AccordionPane ID="AccordionPane6" runat="server">90 <Header><a href="http://links.10026.com/?link=" class="accordionLink">Tabular View of Slot Allocation</a></Header>91 <Content>92 <asp:GridView AutoGenerateColumns="false" AllowPaging="true" ShowFooter="true" ShowHeader="true" ID="gvSlotAvailibily" runat="server" OnPageIndexChanging="gvSlotAvailibily_PageIndexChanging" >93 <Columns>94 <asp:BoundField DataField="DATE" DataFormatString="{0:MM-dd-yyyy}" HeaderText="Date" />95 <asp:BoundField DataField="Available" HeaderText="Available Slot" ItemStyle-HorizontalAlign="Center" />96 <asp:BoundField DataField="TempBookSlot" HeaderText="Temp Booked Slot" ItemStyle-HorizontalAlign="Center" />97 <asp:BoundField DataField="BookedSlot" HeaderText="Booked Slot" ItemStyle-HorizontalAlign="Center" />98 <asp:BoundField DataField="TotalSlot" HeaderText="Total Slot" ItemStyle-HorizontalAlign="Center" />99 </Columns>100 </asp:GridView>101102 </Content>103 </ajaxToolkit:AccordionPane>104 </Panes>105 </ajaxToolkit:Accordion>106107108 </asp:Panel>109 </div>110 </ContentTemplate>111 <Triggers>112 <aspajax:AsyncPostBackTrigger ControlID="lnkaddAgency" EventName="Click" />113 <aspajax:AsyncPostBackTrigger ControlID="lnkNewAd" EventName="Click" />114 <aspajax:AsyncPostBackTrigger ControlID="lnkView" EventName="Click" />115 <aspajax:AsyncPostBackTrigger ControlID="btnadvertiseSubmit" EventName="Click" />116 </Triggers>117118119 </aspajax:UpdatePanel>

but it not working properly

Both should work

ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "<script language='Javascript'> alert('" + Message + "'); </script>", false);

ScriptManager.RegisterStartupScript(this, this.GetType(), "key", " alert('" + Message + "'); ", true);


here problem is not with sendPopupMessage()

actully after 1st validation it doesn't get submit



http://www.asp.net/AJAX/Documentation/Live/mref/O_T_System_Web_UI_ScriptManager_RegisterStartupScript.aspx

Better way you use validators..

But see for more details

Validation controls, which includes theBaseCompareValidator,BaseValidator,CompareValidator,CustomValidator,RangeValidator,RegularExpressionValidator,RequiredFieldValidator, andValidationSummary control are not compatible with UpdatePanel

See it here

http://weblogs.asp.net/scottgu/archive/2007/01/25/links-to-asp-net-ajax-1-0-resources-and-answers-to-some-common-questions.aspx

You can downlaod compatible ersion of validators from here

http://blogs.msdn.com/mattgi/archive/2007/01/23/asp-net-ajax-validators.aspx