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

2012年3月26日月曜日

Response.Redirect and UpdatePanel Problem Again

I can't figure out if I'm doing something wrong, it's just how it is, or it's a bug. If I create an UpdatePanel and place a button in it and then put Response.Redirect in the button's click event, everything works as I would expect and I'm redirected to the page I specified in the event. Now, if I drop a DataList inside the UpdatePanel and then put LinkButtons that have OnCommand and CommandArguement properties inside the DataList's ItemTemplate, response.redirect won't work for those LinkButtons. It just clears the datagrid and remains on the same page.

I've read everything I can find about people having the same problems but everything I read doesn't address buttons inside a DataList. Normal buttons in the UpdatePanel work for me. I'm using Ajax 1.0 RC.

Strange. Could you share your code?

Here's what I tried, and it works fine:

<%@. 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"> protected void item_command(object sender, DataListCommandEventArgs e) { Response.Redirect("http://ajax.asp.net"); } protected void Page_Load(object sender, EventArgs e) { list.DataSource = new string [] { "one", "two", "three" }; list.DataBind(); }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head ID="Head1" runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="sm1" runat="server" /> <asp:UpdatePanel ID="up1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:DataList ID="list" runat="server" OnItemCommand="item_command"> <ItemTemplate> <asp:LinkButton ID="button" runat="server" Text="<%# Container.DataItem%>" CommandName="redirect" /> </ItemTemplate> </asp:DataList> </ContentTemplate> </asp:UpdatePanel> </form></body></html>

I need to get the CommandArgument from the LinkButton, set it to a session variable and then redirect. Here is an example of my code.

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:datalist id="MyList" runat="server" EnableViewState="False" RepeatColumns="4">
<ItemTemplate>
<asp:LinkButton ID="MyLinkButton" runat="server" EnableViewState="FALSE" OnCommand="My_Command" CommandArgument='<%# Eval("MyID") %>'><%# Eval("MyName") %>
</asp:LinkButton>
</ItemTemplate>
</asp:datalist>
</ContentTemplate>
</asp:UpdatePanel>
Public Sub My_Command(ByVal senderAs Object,ByVal eAs System.Web.UI.WebControls.CommandEventArgs) Session("MyID") = e.CommandArgument Response.Redirect("MyDetail.aspx",False)End Sub
 
Thanks!

I haven't tried this yet, but I notice you're passing False as the second argument to Response.Redirect()... does it make a difference if you change that to true? (Or simply drop it as in my example?)

I've tried it all three ways with the same result.


I tried the following code and it seems to work for me too. Have you used Fiddler on any other trace tool to chaeck what the response is from the server?

<%@. Page Language="VB" AutoEventWireup="true" %><script runat="server"> Protected Sub LinkButton1_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs) Session("MyID") = e.CommandArgument Response.Redirect("Default2.aspx") End Sub</script><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" />   <asp:UpdatePanel ID="UpdatePanel1" runat="server" EnableViewState="False"> <ContentTemplate> <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" EnableViewState="False" RepeatColumns="4"> <ItemTemplate> <asp:LinkButton ID="LinkButton1" runat="server" CommandArgument='<%# Eval("AddressID")%>' OnCommand="LinkButton1_Command" Text='<%# Eval("AddressLine1") + Eval("AddressLine2")%>'></asp:LinkButton> </ItemTemplate> </asp:DataList> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString%>" SelectCommand="SELECT TOP 100 Person.Address.* FROM Person.Address"></asp:SqlDataSource> </ContentTemplate> </asp:UpdatePanel>   </form></body></html>

I finally found the problem. In my codefile I have a sub that gets called that fills the datalist in the Page_Load procedure.

As an example:

If Not Page.IsPostBackThen
 'Do some stuff if this isn't a postback UpdateMyDataListEnd If
This worked for everything *except* clicking on the LinkButtons in the Datalist. So what I did was this and it now works for the LinkButtons as well.
 
If Not Page.IsPostBackThen
 'Do some stuff if this isn't a postback
Else UpdateMyDataListEnd If

2012年3月21日水曜日

Rounded Corners cannot accept Width = "__%"

Hopefully, somebody may be able to tell me if I'm doing something wrong here.

All I'm trying to do ismake a panel sit inside of another panel.
Theinner panel must have rounded corners and both panelsmust resize with the browser window.


Without Atlas RoundedCorners I can say:

<asp:PanelID="OuterPanel"runat="server"BorderColor="Black"BorderStyle="Solid"BorderWidth="1px"BackColor="blue"
Style="left: 5%; top: 5%; position: relative"Height="90%"Width="90%">

<asp:PanelID="InnerPanel"runat="server"BorderColor="Black"BorderStyle="Solid"BorderWidth="1px"BackColor="red"
Style="position: absolute; margin-left:10%; margin-top:12%"Height="73%"Width="90%">
</asp:Panel>

</asp:Panel>

and everything behaves and looks fine (minus the rounded corners) - this includes both panels resizing with the window

However... once I add the RoundedCornersExtender and point it at the Inner Panel

<cc1:scriptmanagerid="ScriptManager1"runat="server"/>
<cc2:roundedcornersextenderid="RoundedCornersExtender1"runat="server">
<cc2:RoundedCornersPropertiesRadius="10"TargetControlID="InnerPanel"/>
</cc2:roundedcornersextender>


...The graphics get all confused.
Yes, I've got the rounded corners, but 2 things are wrong.

1. The inner panel stops resizing in Width (resizes ok in height)
2. It looks like a transparent box of almost the same height as the panel is missing from the right of the Inner panel.

The really wierd thing is:
If (on the Inner Panel) I replaceWidth="90%"for Width="700px" Then the above 2 problems are fixed.

But, that leaves me with a panel that doesn't resize with the rest of the controls on my page - totally defeating the point !!

I don't understand why this Atlas control works fine with Height="90%", but not Width="90%"

Can anyone help ?
I've been struggling for ages with this !

Thanks,
Scott

So, no-one has any thoughts on this ?

Aren't there any Atlas type officials out there at least willing to recognise this bug ??


From what I can tell this is a bug... you cannot set the height or width to xxx% when using the Rounded Corners extender. It has never worked for me. So I just make sure that the data I put into the panel is of a predefined height,

Dunno if it will ever get fixed.

Cheers
Graeme


Check out our free rounded panel control for ASP.NET 2, also our free security code image control.http://www.roundedpanel.baysoft-net.co.uk. Hope this helps. It's pretty flexible.


You've got one panel with position: relative and another with position: absolute and you expect them to behave the same? Not going to happen. remove the position: absolute from the second panel.

Also, it looks like you might have an older version of the AJAX Toolkit because of the RoundedCornersProperties entity. Those properties should be in the RoundedCournersExtender tag. I'd recommend downloading the latest version of the toolkit.

RoundedCorners not working correctly in IE7.0 Beta

RoundedCorners not working correctly in IE7.0 Beta - The corners are not working as in IE6.0 - In IE7 the cormers appear in the wrong location - it seems the width is not being interpreted correctly i.e. to small

We're using IE7 internally and have tested in IE6, IE7, FireFox, and Safari. Can you post a repro of what you're seeing?
The simplist way to show you what is happening is to send you an image - the forum doesn't seem to allow images, so is there an email address I could send it to?
Yes but the image won't help us repro/debug it. The best thing is to just paste in your HTML from your ASPX page.

I think I understand the problem now it a problem if the panel has say a table inside itself and the contents get bigger than the original size of the panel - The coners get left behind and the corners do not update to suit this new expand size.