Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need button to fire both javascript function and asp.net sub

Status
Not open for further replies.

arneweise77

Programmer
Apr 25, 2002
46
SE
Hi!

I´m using vb.net together with asp.net and I´ve encuntered a problem. Basically what I want to do is read and write cookies with asp.net, I write a httpcookie and put some info about it in a listbox, then the user can select and delete that cookie.
Did this using asp.net only but then I needed to postback the page twice(?) to let the server know that the cookie expired.
So now I´m trying to delete the cookie with javascript and then do the postback. Tried this with delButton.Attributes.Add("OnClick", "javascript:delCookie();"), but then asp.net sub don´t run. Postback occurs but it doesn´t run the sub I specified with:
<asp:Button
...
OnClick=&quot;delButton_Click&quot;
...>

If I change the &quot;javascript:delCookie();&quot; to &quot;alert('hello');&quot; the postback works as I want!?
Any suggestions??

Thanks!
Arne
 
Not entirely clear on what your goal is, but...

Not sure why you're trying to postback twice. If you're just trying to allow the user to delete the cookie and then refresh the page, why not just do it all in one function?

(Pseudo-Code)
private void delButton_Click()
{
...Delete Cookie (Set expiry)
...Clear listbox of cookies
...Re-populate listbox
}

Is there anything I'm missing, or is this what you're trying to accomplish?

If I'm way off base, I apologize... (Working on my first coffee of the day ;))

-----------------------------------------------
&quot;The night sky over the planet Krikkit is the least interesting sight in the entire universe.&quot;
-Hitch Hiker's Guide To The Galaxy
 
AtomicChip you definitely don´t need to apologize because I didn´t explain what I want to do.
Here goes:
The user can choose a product in another listbox then press a button and a chart is displayed with a bar that represents the hours it takes to make that product, a cookie holds this information(and the listbox I talked about before just holds which product was chosen). Then the user can choose if to store or delete the chart. Upon deletion I delete the cookie and call drawChart(), this function gets hours and date from the cookie and not from the listbox.
Makes sense??

 
Ok, got it to work, had some problem with the javascript...
apologize for taking up your time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top