Solved

asp.net get value from args on postback from javascript, _DoPostBackWithOptions

Posted on 2013-05-20
2
842 Views
Last Modified: 2013-05-22
I am building a list of controls in code behind and putting an id# in a hyperlink.
an HTML hyperlink, not building asp.net controls. (only because I cant figure that out )
I can get it to postback to a button but can't get a value from the postback agument.

 Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'get arg and do something.

end sub

I tried this but cant get the values when the post back happens - it goes to the button1:
<a href="#" onclick="j WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions('button1','12', true, &quot;&quot;, &quot;&quot;, false, false))"   /><br />

<a href="#" onclick="j WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions('button1','44', true, &quot;&quot;, &quot;&quot;, false, false))"   />


I need to list  values - somehow - and when clicking it, it go to code behind with the value of the line.

not wanting to use a gridview.

I have loaded jquery and jquery moble
I'm using vb,net too

thanks, any comments are appreciated.
john
0
Comment
Question by:john
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 36

Accepted Solution

by:
Miguel Oz earned 500 total points
ID: 39183898
You should use ___doPostBack(), check:
http://www.codedigest.com/Articles/ASPNET/320_Doing_or_Raising_Postback_using___doPostBack()_function_from_Javascript_in_AspNet.aspx

In your case the markup will be as follows:
<a href="#" onclick=""javascript:__doPostBack('button1','44')">LinkButton</a>

Open in new window


in your VB code you can get the control id using ('button1')
Request.Params.Get("__EVENTTARGET")
and the argument('44')
Request.Params.Get("__EVENTARGUMENT")

and then add some if logic to call the button handler as a new method to avoid using event args
0
 

Author Closing Comment

by:john
ID: 39189765
got it I had to add

EnableEventValidation="false"
and
 AutoEventWireup="true"

at top of page,
thanks
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question