Click here to Skip to main content
14,329,627 members
   

ASP.NET

 
GeneralRe: WHy is my image not displaying on a certain page? Pin
samflex4-Apr-19 5:59
membersamflex4-Apr-19 5:59 
QuestionLoad event fires twice and QueryString becomes empty!! Pin
pldelosrios2-Apr-19 3:41
memberpldelosrios2-Apr-19 3:41 
Hello,

I'm trying to do one page with two listboxes that filers one grid.
The only requirement is that the selection made by the user must be reflected in the URL so that it can be sent by mail to colleagues with the selection already made


The problem is that Load event fires twice.
First time all parameters are transmitted correctly.
The second time the whole QueryString disappears!!

ASPX Directive:
<%@ Page 
	Language="vb" 
	uiCulture="en-US" 
	culture="de-DE"
	MasterPageFile="XTAB_WO.master" 
	AutoEventWireup="false" 
	CodeFile="LC1vsLC2.vb"
	Inherits="LC1vsLC2" 
	ClientIDMode="Predictable"
%>  


ASPX Code:

<asp:listbox clientidmode="Static" id="LstTipo" style="width:150px;height:100px;" runat="server" datasourceid="SqlDataSource2" datatextfield="FLD_RESULTADO" datavaluefield="FLD_RESULTADO">
<asp:listbox clientidmode="Static" id="LstTMA" style="width:150px;height:100px;" runat="server" datasourceid="SqlDataSource4" datatextfield="FLD_MOD3" datavaluefield="FLD_MOD3">
<dx:ASPxGridView ID="gridview1" runat="server" AutoGenerateColumns="true" DataSourceID="SqlDataSource1">
</dx:ASPxGridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MyCCnn %>"></asp:SqlDataSource>
<asp:Button ID="Button1" runat="server" Text="Select" style="width:150px;" OnClientClick="Populate();"/>
	<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
		ConnectionString="<%$ ConnectionStrings:hacheConnectionString %>" 
		SelectCommand="select '(ALL)' FLD_RESULTADO UNION ALL select distinct FLD_RESULTADO from XXXXXXXXXXXXX">
	</asp:SqlDataSource>
	<asp:SqlDataSource ID="SqlDataSource4" runat="server" 
		ConnectionString="<%$ ConnectionStrings:hacheConnectionString %>" 
		SelectCommand="select '(ALL)' FLD_MOD3 UNION ALL select distinct FLD_MOD3 from XXXXXXXXXXXXX">
	</asp:SqlDataSource>
    <script type="text/javascript" language="javascript">
        function removeParam(key, sourceURL) {
            var rtn = sourceURL.split("?")[0],
			param,
			params_arr = [],
			queryString = (sourceURL.indexOf("?") !== -1) ? sourceURL.split("?")[1] : "";
            if (queryString !== "") {
                params_arr = queryString.split("&");
                for (var i = params_arr.length - 1; i >= 0; i -= 1) {
                    param = params_arr[i].split("=")[0];
                    if (param === key) {
                        params_arr.splice(i, 1);
                    }
                }
                rtn = rtn + "?" + params_arr.join("&");
            }
            return rtn;
        }     

        function Populate() {
            var tma = document.getElementById("LstTMA");
            var tipo = document.getElementById("LstTipo");
            var fe = "";
            var miurl="";
            var miurlIni="";
            var valor = "";
						
	    miurlIni = window.top.location.href + "?";


            if (tipo.selectedIndex >= 0) {
                var selectedtipo = tipo.options[tipo.selectedIndex].text;
                miurl = removeParam("tipo", miurl);
                valor = (selectedtipo == "(ALL)") ? '0' : selectedtipo;
                miurl = miurl + "&tipo=" + valor.replace(" ","_");
            }

            if (tma.selectedIndex >= 0) {
                var selectedtma = tma.options[tma.selectedIndex].text;
                miurl = removeParam("tma", miurl);
                valor = (selectedtma == "(ALL)") ? '0' : selectedtma;
                miurl = miurl + "&tma=" + valor;
            }

            window.top.location.href = miurlIni + miurl.substring(1,999);
        }
    </script>   



CODE-BEHIND:


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim q As String, q_count As String, x As Integer, NumR As Long
        Dim dv As Object

        Dim mpContentPlaceHolder As ContentPlaceHolder
        Dim ddlRp As ASPxRoundPanel
        Dim LstTipo As ListBox, StTipo As String
        Dim LstTMA As ListBox, StTma As String


        mpContentPlaceHolder = CType(Master.FindControl("ContentHolder"), ContentPlaceHolder)
        If Not mpContentPlaceHolder Is Nothing Then
            ddlRp = CType(mpContentPlaceHolder.FindControl("ASPxRoundPanel3"), ASPxRoundPanel)
            If Not ddlRp Is Nothing Then
                LstTipo = CType(ddlRp.FindControl("LstTipo"), ListBox)
                LstTMA = CType(ddlRp.FindControl("LstTMA"), ListBox)
            End If
        End If

        If Request.QueryString.Count > 0 AndAlso ((Not Request.QueryString("pais") Is Nothing) Or (Not Request.QueryString("y4m2d2") Is Nothing) Or (Not Request.QueryString("tipo") Is Nothing) Or (Not Request.QueryString("tma") Is Nothing)) Then
            StTipo = "" : StTma = "" ': Sty4m2d2 = "" 

            If Not (Request.QueryString("tipo") Is Nothing) AndAlso Request.QueryString("tipo").ToString() <> "" Then
                If Request.QueryString("tipo") = "0" Then
                    LstTipo.SelectedValue = "(ALL)"
                    StTipo = ""
                Else
                    LstTipo.SelectedValue = Replace(Request.QueryString("tipo"), "_", " ")
                    StTipo = " AND FLD_RESULT='" & Replace(Request.QueryString("tipo"), "_", " ") & "'"
                End If
            End If

            If Not (Request.QueryString("tma") Is Nothing) AndAlso Request.QueryString("tma").ToString() <> "" Then
                If Request.QueryString("tma") = "0" Then
                    LstTMA.SelectedValue = "(ALL)"
                    StTma = ""
                Else
                    LstTMA.SelectedValue = Replace(Request.QueryString("tma"), "_", " ")
                    StTma = " AND FLD_MOD3='" & Replace(Request.QueryString("tma"), "_", " ") & "'"
                End If
            End If

            q = "SELECT " & StFieldsQuery & " FROM V_BUDA_LC1vsLC2 WHERE 1=1 " & StTipo & StTma '& Sty4m2d2 '& " ORDER BY FLD_ID"
            q_count = "SELECT count(*) NumR FROM V_BUDA_LC1vsLC2 where 1=1 " & StTipo & StTma '& Sty4m2d2

            SqlDataSource11.SelectCommand = q_count

            dv = CType(SqlDataSource11.Select(DataSourceSelectArguments.Empty), DataView)
            NumR = CType(dv.Table.Rows(0)(0), Integer)
            If (NumR > 0) Then
                SqlDataSource1.SelectCommand = q

                gridview1.Visible = True
                LblNoData.Visible = False
            Else
                gridview1.Visible = False
                LblNoData.Visible = True
            End If
        Else
            gridview1.Visible = True
            LblNoData.Visible = False

            q = "SELECT * FROM V_BUDA_LC1vsLC2 WHERE 1=0"
            SqlDataSource1.SelectCommand = q
        End If

        Page.DataBind()
    End Sub

SuggestionRe: Load event fires twice and QueryString becomes empty!! Pin
Richard Deeming2-Apr-19 8:16
mveRichard Deeming2-Apr-19 8:16 
QuestionError 550 Permission denied: Windows Server 7 FTP Server ? Pin
Member 245846722-Mar-19 18:13
memberMember 245846722-Mar-19 18:13 
GeneralRe: Error 550 Permission denied: Windows Server 7 FTP Server ? Pin
Richard MacCutchan22-Mar-19 23:10
protectorRichard MacCutchan22-Mar-19 23:10 
GeneralRe: Error 550 Permission denied: Windows Server 7 FTP Server ? Pin
Member 245846724-Mar-19 18:35
memberMember 245846724-Mar-19 18:35 
QuestionWant to find out differences between two branches (local or remote) in Git Pin
simpledeveloper22-Mar-19 20:47
membersimpledeveloper22-Mar-19 20:47 
AnswerRe: Want to find out differences between two branches (local or remote) in Git Pin
Richard MacCutchan23-Mar-19 2:29
protectorRichard MacCutchan23-Mar-19 2:29 
QuestionMessage Closed Pin
20-Mar-19 0:08
memberMember 1281182220-Mar-19 0:08 
Questionvisual studio for mac, Unexpected character '�' (CS1056) Pin
Member 1182460318-Mar-19 16:25
memberMember 1182460318-Mar-19 16:25 
AnswerRe: visual studio for mac, Unexpected character '�' (CS1056) Pin
Richard MacCutchan18-Mar-19 22:57
protectorRichard MacCutchan18-Mar-19 22:57 
QuestionNot declared or inaccessible due to protection levels - VS 2017 errors Pin
Member 876166718-Mar-19 8:42
memberMember 876166718-Mar-19 8:42 
AnswerRe: Not declared or inaccessible due to protection levels - VS 2017 errors Pin
Richard Deeming18-Mar-19 9:27
mveRichard Deeming18-Mar-19 9:27 
GeneralRe: Not declared or inaccessible due to protection levels - VS 2017 errors Pin
Member 876166718-Mar-19 10:52
memberMember 876166718-Mar-19 10:52 
GeneralRe: Not declared or inaccessible due to protection levels - VS 2017 errors Pin
Richard Deeming19-Mar-19 2:01
mveRichard Deeming19-Mar-19 2:01 
GeneralRe: Not declared or inaccessible due to protection levels - VS 2017 errors Pin
Member 876166719-Mar-19 23:08
memberMember 876166719-Mar-19 23:08 
GeneralGrid view select operation to update data from form view Pin
Member 1418527517-Mar-19 1:01
memberMember 1418527517-Mar-19 1:01 
Questionnamespace error when using namespaces that don't match names ? Pin
Member 245846713-Mar-19 20:26
memberMember 245846713-Mar-19 20:26 
QuestionRe: namespace error when using namespaces that don't match names ? Pin
Richard MacCutchan13-Mar-19 22:24
protectorRichard MacCutchan13-Mar-19 22:24 
AnswerRe: namespace error when using namespaces that don't match names ? Pin
Eddy Vluggen14-Mar-19 2:20
mveEddy Vluggen14-Mar-19 2:20 
SuggestionRe: namespace error when using namespaces that don't match names ? Pin
Richard Deeming14-Mar-19 8:44
mveRichard Deeming14-Mar-19 8:44 
GeneralRe: namespace error when using namespaces that don't match names ? Pin
Member 24584673-May-19 20:35
memberMember 24584673-May-19 20:35 
AnswerRe: namespace error when using namespaces that don't match names ? Pin
Member 245846717-Mar-19 23:04
memberMember 245846717-Mar-19 23:04 
QuestionCapture Search Engine Keyword Pin
Otekpo Emmanuel12-Mar-19 15:09
memberOtekpo Emmanuel12-Mar-19 15:09 
AnswerRe: Capture Search Engine Keyword Pin
F-ES Sitecore13-Mar-19 1:02
mveF-ES Sitecore13-Mar-19 1:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.