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

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

Retrieve value from a dynamically created control inside an UpadetPanel

I would like to dynamically create some controls - tablecells, textboxes, and dropdownlists inside an AJAX UpdatePanel.
How would I retrieve the values that user enters into these controls in my vb.net code behind?
Can you please provide vb.net sample code ??

Here is my code:

'creates the textboxes - works fine

For i = 1 To intUnseatedGuestCount
Dim txtFirstName As New TextBox
txtFirstName.ID = "txtFirstName" + i.ToString
Me.tdNewSeatingCards.Controls.Add(txtFirstName)
Next

'code to retreive the values - produces an error message

Object reference not set to an instance of an object

For i = 1 To Me.hidNewSeatingCardCount.value
strTXTName = "txtFirstName" + i.ToString
Dim myTXT As TextBox = CType(Me.tdNewSeatingCards.FindControl("txtFirstName" + i.ToString), TextBox)
strTest += myTXT.Text + "<br>"
Next

Thank you for your help

You are creating controls dynamically, So on every postback (even in asynchronous postbacks ) you have to create it


OK Here is my code to recreate the controls:

For i = 1 To Me.hidNewSeatingCardCount.Value
Dim txtFirstName As TextBox = CType(Me.tdNewSeatingCards.FindControl("txtFirstName" + i.ToString), TextBox)
txtFirstName.ID = "txtFirstName" + i.ToString
Me.tdNewSeatingCards.Controls.Add(txtFirstName)
strTest += CType(Me.tdNewSeatingCards.FindControl("txtFirstName" + i.ToString), TextBox).Text
Next

There are no error messages, but I am not getting the values that the user enters into the textbox.

Thank you


Hi,

Thank you for your post!

You should place your recreate code in the init event.

The cause of the issue is viewstate process is finished before you recreate your controls!

If you have further questions,let me know!

Best Regards,

retrieve value from a dynamically created control

I would like dynamically create some controls - tablecells, textboxes, and dropdownlists inside an AJAX UpdatePanel.

How would I retrieve the values that user enters into these controls in my vb.net code behind?

Can you please provide vb.net sample code ??

Thank you for your help

http://forums.devx.com/showthread.php?t=16770

http://mail.123aspx.com/ArticleFrame.aspx?res=31558


here is a nice tutorial with example / code on how to create Dynamic controls and how to retrieve values from these dynamic controls.. [Page_Init() event is used here...]

SingingEels : Dynamically Created Controls in ASP.NET

hope it helps./.

2012年3月24日土曜日

Rich Text Editor using Atlas

Hi,

I need to create a basic RTE and was thinking about using some of the Atlas functionality until I realised that of course there is no SelectedText, SelectedLength, SelStart properties on string type controls such as Literal.

Can anyone tell me whether they know of a way that this might be achieved?

Many Thanks,

Grant

SelectedText, SelectedLength and SelStart.

the literal control does generate a specific html element, if any of those properties are present in javascript, you can probably apply them to the literal through javascript.

although, the real technique for the RTE s is using an iframe, the maniuplating the html inside the page contained in the iframe. that gives complete control over the text typed inside the iframe.

let me know if this gives any ideas


http://freetextbox.com/forums/post/6634.aspx

Rounded Corner Extender has problems with dynamic panels

I'm trying to create some panels, which are "glued" to the top and bottom, so the panel resize together with browser. It works fine, until I attach a Rounded Corner Extender. Then the rounded corners are positioned correct with the top, but the height are fixed somewhere near the top.

Here are the panel I try to add rounded corners to:

<asp:PanelID="PanelSideBar"runat="server"Style="position: absolute; top: 100px;left: 10px; bottom: 25px; width: 200px"BackColor="Beige"></asp:Panel>

<

ajaxToolkit:RoundedCornersExtenderID="RCExtender"runat="server"TargetControlID="PanelSideBar"></ajaxToolkit:RoundedCornersExtender>Thanks for reporting this. I have opened work itemhttp://www.codeplex.com/AtlasControlToolkit/WorkItem/View.aspx?WorkItemId=8769 for this.

2012年3月21日水曜日

RoundedCornersExtender - border instead of background color?

Does anyone know if there's a way to use a RoundedCornersExtender on a panel to create add just a border with rounded corners instead of having to set the whole background color?

In other words, picture a white page background, with a white background inside my panel, but i want a rounded black border around the panel. Is this possible?

Thanks in advance for any thoughts/suggestions.

-Gabe

RoundedCorners has a Color property. Set that to black, then set

style="border-left:thin black solid;border-right:thin black solid;"

on your element.


sburke_msft:

RoundedCorners has a Color property. Set that to black, then set

style="border-left:thin black solid;border-right:thin black solid;"

on your element.

A suggestion for futher releases of the toolkit would be to use less CSS and more properties... would help a lot and make development more intuitive...

Regards,

Felipe Oquendo
MCAD


Thanks for the feedback. It might make certain things more discoverable but there's really no way to mimic the power and flexibility found in CSS via properties.
Alas, this doesnt look very good at all. The borders don't meet up nicely with the top and bottom, and they're not nearly the same thickness. Any other suggestions, or am I doing something wrong?

Here's the markup I'm using:
<asp:Panel ID="panTest" runat="server" style="border-left:thin black solid;border-right:thin black solid;">
Some content goes here <br />
Some content goes here <br />
Some content goes here <br />
Some content goes here <br />
Some content goes here <br />
Some content goes here <br />
Some content goes here <br />
</asp:Panel>
<cc1:RoundedCornersExtender ID="RoundedCornersExtender1" runat="server">
<cc1:RoundedCornersProperties Color="black" Radius="6" TargetControlID="panTest" />
</cc1:RoundedCornersExtender
Screenshot here:http://img130.imageshack.us/img130/6744/iescreenshot7mb.gif

Thanks for the screenshot - very helpful.

Try this instead:

<asp:Panel ID="panTest" runat="server" >

<div style="width:100%;border-left:thin black solid;border-right:thin black solid;">
Some content goes here <br />
Some content goes here <br />
Some content goes here <br />
Some content goes here <br />
Some content goes here <br />
Some content goes here <br />
Some content goes here <br />

</div>
</asp:Panel>


Thanks for the suggestion, but that doesn't look any better to me. Did you try it and get nice looking results?

No but I just did and if you make the borders a little wider I think it looks good:

<asp:PanelID="panTest"runat="server">

<divstyle="border-left:5px black solid;border-right:5px black solid;">

Some content goes here

<br/>

Some content goes here

<br/>

Some content goes here

<br/>

Some content goes here

<br/>

Some content goes here

<br/>

Some content goes here

<br/>

Some content goes here

<br/></div></asp:Panel>

ghollombe:

Does anyone know if there's a way to use a RoundedCornersExtender on a panel to create add just a border with rounded corners instead of having to set the whole background color?

In other words, picture a white page background, with a white background inside my panel, but i want a rounded black border around the panel. Is this possible?

The comments seem to have gotten off the original topic, and the original topic interests me a lot.

Let's get back to the original question...could the RoundedCornersExtender be modified to give us a rounded border option (and the option to set the thickness of the border)?

I have a case where we would like a rounded border (slghtly darker color than the content it surrounds). I see what the extender is doing..it adds several 1px high divs above and below. To get the rounding effect, they have left and right margins.

However, if it was modified to do a border, then it would have to work differently, which could be a little tricky. This is because at some point you would need an indented div of the border color that is only borderwidth wide, then a div of the background color, then an indented div of the border color again. I'm not sure if that works by itself or if you'd have to get into tables to do it.

Furthermore, you'd have to put a border on the left and right of the panel.

It would be useful and cool, but definitely more comlicated.


Hi Guys,

You were pretty close. The solution that appears to works across browsers for me is. It is just a shame the RoundedCornersProperties can't be driven from a stylesheet.

<div id="hello" runat="server">
<div style='border-left:thin black solid;border-right:thin black solid;'>
test
</div>
</div>
<cc1:RoundedCornersExtender ID="DropShadowExtender1" runat="server">
<cc1:RoundedCornersProperties TargetControlID='hello' Radius="10" Color="black" />
</cc1:RoundedCornersExtender>


have you tried something like this...

<asp:PanelID="Panel1"runat="server"Height="50px"Width="500px"BackColor="lightBlue"style="margin:10px 10px 10px 10px"><asp:PanelID="Panel2"runat="server"height="42px"BackColor=Whitestyle="margin: 0px 4px 0px 4px">

TEST

</asp:Panel></asp:Panel><AjaxToolkit:RoundedCornersExtenderID="RoundedCornersExtender1"runat="server"TargetControlID="Panel1"Radius=4/>

<AjaxToolkit:RoundedCornersExtenderID="RoundedCornersExtender2"runat="server"TargetControlID="Panel2"Radius=4/>

It may be one too many panels for you but it works

RoundedCornersExtender and CollapsiblePanelExtender dont work together on IE7

This code works well on Firefox.

I need to create Panels that have rounded corners and that are collapsable...

on IE7 the panel flashes and does not expand.

Thanks,

Eyal

<

asp:ScriptManagerID="ScriptManager1"runat="server"></asp:ScriptManager><divid="divFiltersHeader"><asp:PanelID="pnlFiltersHeader"Width="520"Height="30"CssClass="TransHistoryFiltersHeader"runat="server"><divstyle="float: left;padding: 5px;vertical-align: middle;">Advanced Filters</div></asp:Panel></div><divid="divFilters"><asp:Panelid="pnlFilters"CssClass="TransHistoryFiltersTable"runat="server"><p>Here come the filters !!!</p><p>filter 1</p><p>filter 2</p><p>test:<asp:DropDownListID="DropDownList1"runat="server"><asp:ListItem>test1</asp:ListItem><asp:ListItem>test2</asp:ListItem><asp:ListItem>test3</asp:ListItem></asp:DropDownList></p><p>filter 4</p></asp:Panel></div><toolkit:CollapsiblePanelExtenderID="cpeFiltersPanel"runat="server"TargetControlID="pnlFilters"ExpandControlID="pnlFiltersHeader"CollapseControlID="pnlFiltersHeader"Collapsed="true"SuppressPostBack="true">

</toolkit:CollapsiblePanelExtender><toolkit:RoundedCornersExtenderID="RoundedCornersExtender1"runat="server"TargetControlID="pnlFiltersHeader"Radius="5"></toolkit:RoundedCornersExtender>

I don't know if you were able to solve this problem or not but I had the same issue and was able to get around it. It appears that when both extenders are calling the same panel, the CollapsiblePanelExtender breaks. To solve this I simply nested thepnlFiltersHeaderpanel, as you have called it inside a new panel and a div and set Corners="Top". I also nested the area that expands and collapses inside a new panel and div and set Corners="Bottom" and pointed to each with seperate RoundedCornersExtender's. This allowed me to have a title that is one color and a bottom that expands in another color, but the form looks as if it is a continuous piece.

My solution is setup as follows (To save as much space as possible I removed all of the labels and text boxes and replaced them with ".......CONTENT..........":

<script>function pageLoad() {

document.getElementById(

'panelarea').style.display ="";

}

</script><asp:ScriptManagerID="ScriptManager1"runat="server"></asp:ScriptManager>

<

asp:PanelID="Panel3"runat="server"style="width:287px"BackColor="SteelBlue"> <div>

<asp:PanelID="Panel1"runat="server"style="cursor:hand; width:287px;"BackColor="SteelBlue"Width="180px">

......CONTENT......

</asp:Panel> </div></asp:Panel><asp:PanelID="Panel4"runat="server"style="width:287;"BackColor="Gainsboro"Width="287px"> <div> <divid="panelarea"style="display: none;"> <asp:PanelID="Panel2"runat="server"style="cursor:hand; overflow:hidden;"BackColor="Gainsboro"Width="287px"Height="0"> <div> .......CONTENT.........

</div> </asp:Panel> </div> </div></asp:Panel>

<cc1:CollapsiblePanelExtenderID="CollapsiblePanelExtender1"runat="server"TargetControlID="Panel2"CollapsedSize="0"ExpandedSize="275"Collapsed="False"ExpandControlID="Panel1"CollapseControlID="Panel1"AutoCollapse="False"AutoExpand="False"ScrollContents="False"ImageControlID="Image1"ExpandedImage="~/Images/collapse.jpg"ExpandedText="Hide Details"CollapsedImage="~/Images/expand.jpg"CollapsedText="Show Details..."ExpandDirection="Vertical"SuppressPostBack="true"></cc1:CollapsiblePanelExtender>

<cc1:RoundedCornersExtenderID="RoundedCornersExtender1"runat="server"TargetControlID="Panel3"Radius="6"Corners="Top"></cc1:RoundedCornersExtender><cc1:RoundedCornersExtenderID="RoundedCornersExtender2"runat="server"TargetControlID="Panel4"Radius="6"Corners="Bottom"></cc1:RoundedCornersExtender>