Hi Rajendra,
I have the following code behind.
private void Page_Load(object sender, System.EventArgs
e){
if (Page.IsPostBack)
{
lblMessage.Text = "hello";
}else if (!Page.IsPostBack) {
DateTime datNow = DateTime.Now;
string today = datNow.ToString("d");
txtBDate.Value = today;
}
}
private void btnCalendar_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
bDateCalendar.Visible = true;
}
When i click on the image button, It executes
(Page.IsPostBack) and not (!Page.IsPostBack) and shows
the calendar. If I take out the (Page.IsPostBack)
everything works fine. I understand that Page_Load is
triggered if i click on the image button and I only
want to triger (Page.IsPostBack) if i click on the
Submit button. Please help. Thanks
Chris Andrada
--- Rajendra Appalla <[EMAIL PROTECTED]>
wrote:
> For any postback event, the Page_Load event runs.
> Only after this, the
> corresponding event is handled.
>
> So if you have an event btnCalendar_Click wired to
> the button, then
> first Page_Load runs, then this event
> btnCalendar_Click gets executed.
>
>
> If you do not want some code inside the Page_Load
> event not run for
> postbacks, then you need to put that inside an if
> condition that checks
> for postback as:
> If ( ! IsPostBack)
> {
> }
>
> If your problem is that the event btnCalendar_Click
> is not getting
> executed, check to see whether the event is properly
> wired to the
> button. If not, then go to the design part of the
> aspx page and double
> click your button to wire the button to its event.
>
> Hope this helps.
>
> Rajendra.
>
>
> _____
>
> From: christopher andrada
> [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, December 21, 2004 12:17 PM
> To: [email protected]
> Subject: [AspNetAnyQuestionIsOk] How to prevent
> Image Button from
> triggering IsPostBack
>
> Hi All,
>
> The following code below is an image button that
> triggers the visibility of the calendar and populate
> the text box with the chosen date. However, if I
> click on the image button, IsPostBack is getting
> triggered located at Page_Load(). This button is
> suppose to trigger another function called
> btnCalendar_Click. Please advise on what i'm
> suppose
> to do. Thanks.
>
> <td width="442"><INPUT class="input2" id="txtBDate"
> disabled type="text" size="30" name="txtBDate"
> runat="server">
> <asp:imagebutton
> id="btnCalendar"
> runat="server"
> ImageUrl="images/b_calendar.gif"
> ImageAlign="AbsMiddle"
>
> CausesValidation="False"
> Autopostback="False"></asp:imagebutton><asp:calendar
> id="bDateCalendar" runat="server"
> DayNameFormat="FirstLetter" BorderStyle="Solid"
>
> BackColor="GhostWhite"
> BorderColor="Gainsboro"
> Visible="False" ShowGridLines="True">
>
> <SelectorStyle
> BorderColor="Maroon"></SelectorStyle>
>
> <DayHeaderStyle
> BackColor="Peru"></DayHeaderStyle>
>
> <OtherMonthDayStyle
> BackColor="Tan"></OtherMonthDayStyle>
>
> </asp:calendar></td>
>
>
>
> __________________________________
> Do you Yahoo!?
> The all-new My Yahoo! - Get yours free!
> http://my.yahoo.com
>
>
>
>
>
> Yahoo! Groups Sponsor
> ADVERTISEMENT
> click here
>
<http://us.ard.yahoo.com/SIG=1296tcg8n/M=294855.5468653.6549235.3001176/
>
D=groups/S=1705006764:HM/EXP=1103735816/A=2455396/R=0/SIG=119u9qmi7/*htt
> p:/smallbusiness.yahoo.com/domains/>
>
>
<http://us.adserver.yahoo.com/l?M=294855.5468653.6549235.3001176/D=group
> s/S=:HM/A=2455396/rand=430167988>
>
> _____
>
> Yahoo! Groups Links
> * To visit your group on the web, go to:
>
> http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
>
> * To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
>
<mailto:[EMAIL PROTECTED]
> cribe>
>
> * Your use of Yahoo! Groups is subject to the Yahoo!
> Terms of
> Service <http://docs.yahoo.com/info/terms/> .
>
>
> [Non-text portions of this message have been
> removed]
>
>
__________________________________
Do you Yahoo!?
All your favorites on one personal page � Try My Yahoo!
http://my.yahoo.com
------------------------ Yahoo! Groups Sponsor --------------------~-->
$4.98 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/Q7_YsB/neXJAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/