Solved

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

Posted on 2013-05-20
2
825 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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