Link to home
Start Free TrialLog in
Avatar of kdeutsch
kdeutschFlag for United States of America

asked on

Link button not responsing to single click

I had to turn a link button from a hyperlink button becuase of the way i load a page it did not like the pre-render of the hyperlink, I turned it to a link button so that i can still pass values but it takes 2 clicks of the link button for it to work.  Then if I am on a pge and someone passes vlues to the link button and exports data and then they go back and pass another set of data, they agian have to click on it twice to get correct data.  I am just trying to pop-up another page and send session state to it to export to excel.  What am I doing wrong.


Protected Sub lnkExport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkExport.Click
        Dim Type As Integer = 4
        Dim DepID As Integer = ddlDeployment.SelectedValue
        Dim BnID As String = ddlBn.SelectedValue
        Dim UICId As Integer
        Dim Cat As Integer
        Dim task As Integer
        Dim Pick As Integer = rbPick.SelectedValue

        If ddlUic.SelectedValue = Nothing Then
            UICId = 0
        Else
            UICId = ddlUic.SelectedValue
        End If

        If ddlCategory.SelectedValue = Nothing Then
            Cat = 0
        Else
            Cat = ddlCategory.SelectedValue
        End If

        If ddlTask.SelectedValue = Nothing Then
            task = 0
        Else
            task = ddlTask.SelectedValue
        End If

        If Pick = 0 Then
            Session("Type") = Type
            Session("SSN") = HFID.Value.ToString
            Session("Cat") = Cat
            Session("task") = task
        Else
            Session("Type") = Type
            Session("Pick") = Pick
            Session("DepID") = DepID
            Session("BnID") = BnID
            Session("UICId") = UICId
            Session("Cat") = Cat
            Session("task") = task
        End If

        lnkExport.Attributes.Add("onclick", "window.open('ExcelExport.aspx')")
    End Sub

Open in new window

SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ok, just do this for now, Line 43:

lnkExport.Attributes.Add("onclick", "window.open('ExcelExport.aspx')")

-->

response.write("<script>window.open('ExcelExport.aspx')</script>")

Avatar of kdeutsch

ASKER

All,

OkNiether solution is working for me .
For Codecruiser I get a blue underline under teh Me  (value of reports_taskManage cannot be converted to system type)

hainKurt
Response.write will not work for me as it is in an update panel
Is this all in a page? Me should translate to Page
CodeCruiser:

Ok see what you mean by it should be somewhere else, I changed it to my my on page load event and it works on single click now.
try this

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_pageLoaded(pageLoaded);
function pageLoaded(sender, args){
  window.open('ExcelExport.aspx');
}

and comment out line 43
CodeCruiser:,

The page is within a masterPage format, so that might be the reason it did not work, I have had so much trouble using master pages, when it comes up using javscript events and exports.
it works on single click, but at the same time your server code works :)

so you open ExcelExport.aspx without running server code, without setting your session variables... this is not what you want...

probably in ExcelExport.aspx you are using those session variables, and this way they are not set yet...

this comment is for post 37065977
HainKurt:,

Don't like to use session variables and this is reason why, but I need to transfer sensitive data and don't wnat o do it thorugh the URl and get post will not work, I tired classes but sometimes they do not get iniliazed fro some reason.  But I need to find a new solution becuase when our server is slow the session varialbes seem not to work.  I need to figure out how to export to excel in a page that uses a master page in update panels.  So far I have olny had lots of problems and errors.  I am trying to encrypt URl right now and it works except for one little stinking number it doe snto like.  So if you have any advice, I'll take it.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks for the help