Last post Sep 04, 2013 02:53 AM by email@example.com
Jul 24, 2013 04:44 PM|roserex1|LINK
here is my code
Private Sub cmdArchive_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdArchive.Click
Dim archiveMode As Integer = -1
Dim dDate As DateTime? = Nothing
Dim today As DateTime = Date.Today
Dim tomorrow As DateTime = today.AddDays(1)
If txtArchiveDate.SelectedDate.HasValue Then
dDate = txtArchiveDate.SelectedDate.Value
If dDate = tomorrow Then
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "Yes", "confirm()", True)
Based on the result from confirm function i need to execute the server side code, if yes means execute the rest of the srever side code if no means go back to the web page to select other values.
Jul 24, 2013 05:33 PM|AidyF|LINK
in your code behind. You need to take time to first understand how web technology and asp.net works.
What you have to do is put the code you want to run in a seperate function. You put a confirm button on your page and you attack a click handler to it. Pushing the button posts the page back to your server and the click handler runs, and you then run the
rest of your code. Basically it is a two-stage process. You generate a button in your normal page load, then you react to that button being clicked and run your code that needs run when the user confirms.
You really have to start from the very beginning and go through a book or online tutorials about how asp.net works as you haven't got the fundamentals understood yet, and without understanding those you will find it hard to code your website.
Jul 24, 2013 05:46 PM|roserex1|LINK
thanks AidyF. Can you help me to solve this probelm?
when the user selects the date which is equal to tomorrow then they will click archive button i need to alert them that it is tomorrow date so their document will not be shown tomorrow.
my question is how can ia call this alert from serverside on button click event?
pls help me to decide.
Jul 24, 2013 06:13 PM|AidyF|LINK
<asp:Calendar ID="txtArchiveDate" runat="server"/>
<asp:Button ID="cmdArchive" runat="server" Text="Archive" OnClick="cmdArchive_Click" />
<asp:Panel ID="PanelConfirm" runat="server" Visible="false" EnableViewState="false">
You picked tomorrow
<asp:Button ID="cmdConfirm" runat="server" Text="OK" OnClick="cmdConfirm_Click" />
protected void cmdArchive_Click(object sender, EventArgs e)
// Get just the date, not the time
DateTime tomorrow = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
// Add a day to get tomorrow's date
tomorrow = tomorrow.AddDays(1);
DateTime dDate = txtArchiveDate.SelectedDate;
if (dDate == tomorrow)
// Tomorrow was picked so show the Confirm panel
PanelConfirm.Visible = true;
// Just do the work now with no confirmation
protected void cmdConfirm_Click(object sender, EventArgs e)
// User has confirmed tomorrow is ok so do the work
private void DoWork()
// Your code goes here
Jul 25, 2013 08:50 AM|roserex1|LINK
Thanks Aidyf for clearly expalining the code. But I need to show a warning message when the user clicks the tomorrow date. Based on the choice of OK or Cancel button then i ned to perform the rest of the server side code. how to show the warning message
in this scenario?
Sep 04, 2013 02:53 AMfirstname.lastname@example.org|LINK
Try this code posted here