c# - Check to call sql script from different page? -
i have 2 pages - first page has 2 buttons , clicking on either of them run different sql queries , transfer them second page in gridview. upon page load, have 2 different if statements: first 1 run first query , second run second query. question - how check see if button clicked?
here sample of code:
public partial class page2: system.web.ui.page { protected void page_load(object sender, eventargs e) { if (page1 button1 clicked) //this need { //run sql... } else if (page1 button2 clicked) //this similar first { //run sql... } } }
you use session state store button clicked. in button event, have
protected void button1_onclikc(object sender, eventargs e) { session["whichbuttonwasclicked"] = "button1"; }
on page load of next page can read session value.
if (session["whichbuttonwasclicked"] == "button1") { // button 1 clicked } else { //button 2 }
another option pass button click information url parameter. store information in cookie, store in db , retrieve later. lots of options!
Comments
Post a Comment