Avatar of Mehram
Mehram
Flag for Pakistan asked on

On click

Hi Experts,
I am using below mentioned code on click; I need when user click link its go for the check count1 value then open linked page in same browser otherwise not.
Please help

<a runat="server" id="btnDealFinalize" class="tryitbtn" href="~/clientOpening/approvalForm.aspx" target="_blank"> Login For Approval</a>

protected void btnDealFinalize_click(object sender, EventArgs e)
        {
            if (count1 == "A")
            {
                Response.Redirect("clientOpening/dealfinalizeform.aspx");
            }
           
        }
C#

Avatar of undefined
Last Comment
rajeeshmca

8/22/2022 - Mon
Luis Pérez

And... what's exactly your question? Is your code working bad? Do you got any exception?
Mehram

ASKER
Actually I need to open page "approvalForm.axpx on click on same page after validation

<a runat="server" id="btnApproval" class="tryitbtn" href="~/clientOpening/approvalForm.aspx" target="_blank" onclick="btnDealFinalize_click"> Login For Approval</a>


C sharp coding is as follows:

protected void btnDealFinalize_click(object sender, EventArgs e)
        {
            if (getEmp().Count > 0)
            {
                Response.Redirect("clientOpening/approvalForm.aspx");
            }
            else
            {
                msgLabel.Text = "Sorry no record found";
            }
           
        }
ASKER CERTIFIED SOLUTION
Roopesh Reddy

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
dejaanbu

you just remove the href attribute and target attribute from your anchor tag code .
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
rajeeshmca

Hi,

Actually you have used a anchor tag (<a>) which is a client side control. So it does not associate the server side click event.

instead write a javascript function to check the count and accordingly make the redirection.

Otherwise you can change the anchor <a> tag to Linkbutton as roopeshreddy has said.

Regards
Rajeesh