Showing posts with label custom. Show all posts
Showing posts with label custom. Show all posts

Saturday, March 24, 2012

Trigger problem

Hello, I have an custom control with an event, Something like this

Partial

Class CustomControl_SearchInherits System.Web.UI.UserControl

End Class

Therein i have declared an event:

PublicEvent SelectedIndexChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)

and in the html i have created an Listbox

<ASP:ListboxSelectionMode="Multiple"ID="_Listbox"runat="server"AutoPostBack="true"Height="100%"Width="400px"/>

then on the event Listbox.selectedIndexChanged i raise the event SelectedIndexChanged.

ProtectedSub Listbox_SelectedIndexChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles _Listbox.SelectedIndexChanged RaiseEvent SelectedIndexChanged(sender, e)EndSubNow when i try to hook up a selectedIndex event (from my custom control) on the TRIGGER property from the update panel, it wont work, Why not?, It doesnt even apear in the event property's of my custom control

Could you specify the control composition?

I mean , whether the update panel holds an instance of your CustomControl_Search, or the ListBox itself.

If it is the first case, it is quite natural that the update panel cannot be triggered by the SelectedIndex event of the list box.

Probably you could paste some more code here ?

Yani


Ok. Here is some more code:

This is the definition of the custom control

<%@.ControlLanguage="VB"AutoEventWireup="false"CodeFile="Search.ascx.vb"Inherits="CustomControl_Search"%>

<tablewidth="100%"height="100%"cellspacing="0"cellpadding="0"border="0"id="TableNav">

<trheight="12px">

<tdrowspan="4"style="width: 400px"class="IL">

<ASP:ListboxSelectionMode="Multiple"ID="_Listbox"runat="server"

Height="100%"Width="400px"/></td>

</tr>

</table>

ProtectedSub Listbox_SelectedIndexChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles _Listbox.SelectedIndexChanged

RaiseEvent SelectedIndexChanged(sender, e)

EndSub

PartialClass CustomControl_Search

Inherits System.Web.UI.UserControl

' declare events

PublicEvent SelectedIndexChanged(ByVal senderAsObject,ByVal eAs system.EventArgs)

PublicEvent Find_Clicked()

' handle event (in customcontrol)

ProtectedSub Listbox_SelectedIndexChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles _Listbox.SelectedIndexChanged

RaiseEvent SelectedIndexChanged(sender, e)

EndSub

EndClass

Then I use this custom contol in an aspx page, with 4 update panels, witch have a trigger on the SelectedIndexChanged event raised by Searchpnl

<tdcolspan="3"><uc4:SearchID="Searchpnl"runat="server/></td>

<cc1:UpdatePanelID="UpdatePanel1"runat="server"RenderMode="Inline">

<ContentTemplate>

-- Content --

</ContentTemplate>

<Triggers><cc1:ControlEventTriggerControlID="Searchpnl"EventName="SelectedIndexChanged"/></Triggers>

</cc1:UpdatePanel>

But I the whole page is updated, and I won't only the update panel to be updated. (that's where its for).

I can't see the SelectedIndexChanged event in the property's. I can't see it in the task pane from the updatepanel either.

Thanks in advance


If you want to get only the update panel updated, you need to put your search control into the update panel.

Other wise it wouldn't know whether to make a regular page post back or an ajax one.

If it does not work try registering your search control in the script manager

ScriptManager1.RegisterAsyncPostBackControl(Searchpnl);

Cheers,

Yani


While we work closely with the ASP.NET AJAX team when developing the Toolkit, they're the real experts on general ASP.NET AJAX issues. Your problem doesn't seem to be directly related to the Toolkit, so we'd appreciate if you considered posting to one of theother newsgroups such asAJAX Discussion and Suggestions. Your post will be more helpful to others looking for similar advice if it's in the right place. Thank you!

hi,

how can an activex control trigger an event of the parent form's control?

for example, I have an activex control which is a button that when clicked, it will output the content of a textbox.

Public Function setText(txt As String)
msg = txt
End Function

Private Sub Button_login_Click()
MsgBox msg

End Sub

After the msgbox is displayed, I want to clear the text in the textbox located in the parent form.

Any idea?

thanks!

Sheila

Triggering custom client-side javascript after an asp.net ajax postback

I'm working on a form that I wrote a ton of javascript for. The page is also processed server-side through asp.net.

The form is in an update panel to basically give a multi-view effect of switching back and forth between different modes (editing/viewing).

I want my javascript to trigger every time I go into edit mode. To accomplish this, I came up with the following 'hack' to do it.


<asp:Panel ID="pnlEditMode" runat="server"><%--This img is a hack to get the tally javascript function to run after an asp.net ajax postback--%><img onerror="tally(this);" src="http://pics.10026.com/?src=" style="display: none;" /></asp:Panel>

It basically just shows/hides the panel depending on what mode it is.

It works great, just wondering if there's a better way.

Thanks


It looks like you should be using the ScriptManager.RegisterStartupScript() method.

ScriptManager.RegisterStartupScript(this.updatePanel,

this.updatePanel.GetType(),

"tally",

"tally()",

true);

Call it sometime during the asynchronous PostBack request.

Mark

Wednesday, March 21, 2012

Trouble w/ Atlas and Custom User Control

I am trying to create a simple user control that shows a hidden div when an imagebutton is clicked. It works perfectly in a regular page, but in a user control it is conventionally posting back rather than refreshing via Atlas. I have an <atlas:ScriptManager> tag in the page for the control. Below is my code for the control:

<%@dotnet.itags.org. Control Language="C#" AutoEventWireup="true" CodeFile="RatingsBar.ascx.cs" Inherits="UserControls_RatingsBar" %>
<asp:ImageButton ID="showBarGraphButton" runat="server" ImageUrl="~/_Images/bargraph.gif"
OnClick="showBarGraphButton_Click" />

<atlas:UpdatePanel ID="updatePanel1" runat="server" RenderMode="Inline">
<Triggers>
<atlas:ControlEventTrigger ControlID="showBarGraphButton" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Panel ID="barGraphPopup" CssClass="popupHide" runat="server">
<asp:Image ID="sampleImage" runat="server" ImageUrl="~/_Images/barGraphExample.gif"/>
</asp:Panel>
</ContentTemplate>
</atlas:UpdatePanel>

Below is my code for the default.aspx page:
<%@dotnet.itags.org. Page Title="Hi There" Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"Inherits="_Default" %><%@dotnet.itags.org. Register TagPrefix="uc" TagName="Karmevent" Src="~/_UserControls/Karmevent.ascx" %><%@dotnet.itags.org. Register TagName="RatingsBar" TagPrefix="uc" Src="~/_UserControls/RatingsBar.ascx" %><!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><link href="_Stylesheets/StyleSheet.css" rel="stylesheet" type="text/css" /><atlas:ScriptManager ID="ScriptManager" runat="server" /></head><body><form id="form1" runat="server"><uc:RatingsBar ID="rb1" runat="server" /></form></body></html>
Nevermind, everyone. I re-did the code from scratch and it works. I still have no idea what I did wrong, but it's working now.