473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

GetPostBackEventReference Problem

1
My page has 2 usercontrols dynamically created. Both implement IPostBackEventHandler. I created the RaisePostBackEvent method. In the parent page, I used GetPostBackEventReference. The first time, it works fine. In the next few clicks need to click 2 times to enter the RaisePostBackEvent. Anyone have any tips? The following code:

Parent Page
Expand|Select|Wrap|Line Numbers
  1. Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
  2.         CarregaUserControl()
  3. End Sub
  4.  
  5. Private Sub CarregaUserControl()
  6.         divControls.Controls.Clear()
  7.  
  8.         Select Case p_Step
  9.             Case WizardStep.PersonalData
  10.                 uc_usrDadosPessoais = CType(LoadControl("~/UserControl/User.ascx"), UserControl_User)
  11.                 divControls.Controls.Add(uc_usrDadosPessoais)
  12.  
  13.                 'lnkPersonalData.OnClientClick = "LinkClicado(1);" + Page.ClientScript.GetPostBackClientHyperlink(uc_usrDadosPessoais, "GERAREVENTO") + ";"
  14.                 'lnkCategory.OnClientClick = "LinkClicado(2);" + Page.ClientScript.GetPostBackClientHyperlink(uc_usrDadosPessoais, "GERAREVENTO") + ";"
  15.                 lnkPersonalData.Attributes.Add("onclick", "LinkClicado(1);" + Page.ClientScript.GetPostBackEventReference(uc_usrDadosPessoais, "GERAREVENTO") + ";document.forms[0].submit();")
  16.                 lnkCategory.Attributes.Add("onclick", "LinkClicado(2);" + Page.ClientScript.GetPostBackEventReference(uc_usrDadosPessoais, "GERAREVENTO") + ";document.forms[0].submit();")
  17.             Case WizardStep.Category
  18.                 uc_usrCategorias = CType(LoadControl("~/UserControl/UserCategory.ascx"), UserControl_UserCategory)
  19.                 divControls.Controls.Add(uc_usrCategorias)
  20.  
  21.                 lnkPersonalData.Attributes.Add("onclick", "LinkClicado(1);" + Page.ClientScript.GetPostBackEventReference(uc_usrCategorias, "GERAREVENTO") + ";document.forms[0].submit();")
  22.                 lnkCategory.Attributes.Add("onclick", "LinkClicado(2);" + Page.ClientScript.GetPostBackEventReference(uc_usrCategorias, "GERAREVENTO") + ";document.forms[0].submit();")
  23.         End Select
  24.     End Sub
  25.  
  26. Private Sub UCEvent(sender As Object, e As System.EventArgs) Handles uc_usrDadosPessoais.UCEvent, uc_usrCategorias.UCEvent
  27.         p_StepPrevious = p_Step
  28.         Select Case p_StepPrevious
  29.             Case WizardStep.PersonalData
  30.                 uc_usrDadosPessoais.SaveData()
  31.             Case WizardStep.Category
  32.                 uc_usrCategorias.SaveData()
  33.         End Select
  34.  
  35.         p_Step = Integer.Parse(hdnLinkClicado.Value)
  36.         CarregaUserControl()
  37.     End Sub
UserControl
Expand|Select|Wrap|Line Numbers
  1. Public Event UCEvent As EventHandler
  2. Public Overrides Sub RaisePostbackEvent(ByVal eventArgument As String)
  3.         Try
  4.             If eventArgument.Equals("GERAREVENTO") Then
  5.                 RaiseEvent UCEvent(Me, New EventArgs())
  6.             End If
  7.         Catch ex As Exception
  8.  
  9.         End Try
  10.     End Sub
Jan 20 '12 #1
0 1915

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: John Owens | last post by:
I use in Render( HtmlTextWriter output) : //-------------------------------------------------------------------------- output.WriteBeginTag( "a" ); if( ID != null ) output.WriteAttribute(...
0
by: Bort | last post by:
Hello, GetPostBackEventReference(control) returns something like this: __doPostBack('LinkButton1','') but as you can see this does not return the client side script of the button that...
0
by: Mike Hofer | last post by:
Hi everyone. I could really use some help. First, the backstory: ===================== I *really* need a 3-state checkbox for my ASP.NET application. Specifically, I need one that lets me set...
1
by: zoneal | last post by:
I am working on an application that displays a grid with dropdownboxs in various parts of this grid. Now the entire gird is generated dynamically based on user interaction, so i have put the code...
1
by: Mr Newbie | last post by:
I still have a few questions here. Ive been following some examples in a Microsoft Press book on this and have produced a small calculator control which I have written most of the code for. My...
1
by: Marko Vuksanovic | last post by:
I am trying to implement an upload progress indicator using atlas, using the following workaround: http://forums.asp.net/thread/1321664.aspx This is the code in FileUpload.apsx file is as...
2
by: bay_dar | last post by:
Hi, I have an internal ASP.NET application that I'm are using to send e-mails out based on a single milepost or milepost range entered. I'm trying to do two things when a user clicks on the...
2
by: =?Utf-8?B?TWFyaw==?= | last post by:
I am writing a control and want to handle an OnClick event on the client-side before then conforming to the postback mechanism. I have got the server-side events working for my OnClick event by...
9
by: =?Utf-8?B?TWFyYyBXb29sZnNvbg==?= | last post by:
I have what seems to be a relatively simple problem when attempting to simulate a postback in ASP.NET from JavaScript. My scenario is (and please don't ask me why) that I have an HTML <a>nchor...
1
by: Nariban Barkan | last post by:
I am using this code for preventing double click to button (btnInsert), i add this on Page_Load event. ******************************** StringBuilder sb = new StringBuilder(); sb.Append("if...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.