Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    passing variables

    Hi,

    I have an Textbox and 2 submit buttons (asp: hyperlink) in the main page and I have an iframe to host the contents of either button. What do I need to correct my code?


    .... Mainpage.....

    Code:
    <f o r m id="xyz" runat="s e r v e r"> 
    <div id="inputbox" style="......"> 
    input: 
    <asp:TextBox Width="75px" ID='textSer' runat="server" /> 
    </div> 
    <div id="buttn1" style="...."> 
    
    <!-- I HAVE PROBLEM HERE AFTER ? ....> 
    <asp:hyperlink ID='firstbuttn' NavigateUrl="page1.aspx?ser=<%#@textSer.text %>" 
    
    Target="test_iframe" ImageUrl="link1.jpg" runat="server" /> 
    
    </div> 
    <div id="buttn2" style="position:absolute; left:0px; top:51px;width:331px; height:25px;z-index:5; visibility:visible;"> 
    
    <!-- I HAVE PROBLEM HERE AFTER ? ....> 
    <asp:hyperlink ID='secondbuttn' NavigateUrl="page2.aspx?ser=<%#@textSer.text %>" 
    
    Target="test_iframe" ImageUrl="link2.jpg" runat="server" /> 
    </div> 
    
    <div id= "iframecontentarea" style="..."> 
    <iframe id="iframe_id" name="test_iframe" src="blank.htm" style="..."></iframe> 
    </div>
    ..... page1/page2.aspx....(different stored procedure will be used)....

    Code:
     Sub Page_Load()
            If Not IsPostBack Then
               Dim connect As SqlConnection 
               Dim myDataList As SqlDataReader 
               connect = New SqlConnection("server=mysqlservername;UID=myUsername;PWD=mypasswrd;Database=mydbname") 
               Dim cmd As New SqlCommand("sp_mystoredproc1/sp_mystoreproc2", connect) 
    cmd.CommandType = CommandType.StoredProcedure 
    
    'I HAVE TROUBLE WITH THIS LINE 
    cmd.Parameters.AddWithValue("@serialNo", ??????.Text) 
    
    connect.Open() 
    myDataList = cmd.ExecuteReader() 
    Repeater1.DataSource = myDataList 
    Repeater1.DataBind() 
    
    
    myDataList.Close() 
    connect.Close() 
    end if
    endsub
    
    .... 
    
    <body> 
    ... 
    <asp:Repeater ID="Repeater1" runat="server" > 
    ..... 
    
    <ItemTemplate> 
    <tr > 
    <td style="..."><%#Container.DataItem("abc")%>:</td> 
    <td style="...."><%#Container.DataItem("xyz")%></td> 
    
    </tr> 
    </ItemTemplate>
    Last edited by vinyl-junkie; 04-25-2007 at 03:33 AM. Reason: Added code tags

  • #2
    New Coder
    Join Date
    Mar 2007
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts
    okay, advice #1: place code in code tags, please ^^

    2- <f o r m id="xyz" runat="s e r v e r"> I hope you dont have that spacing in the real page cuz that can be enough to make things go funny, try
    <form id="xyz" runat="server">

    Code:
    <asp:hyperlink ID='secondbuttn' NavigateUrl="page2.aspx?ser=<%#@textSer.text %>"
    Target="test_iframe" ImageUrl="link2.jpg" runat="server" /> 
    
    ...
    
    cmd.Parameters.AddWithValue("@serialNo", ??????.Text)
    you're passing the serialNo through the url, as far as I can see, so in your code you should have:
    cmd.Parameters.AddWithValue("@serialNo", Request.QueryString("ser"))

    hope that answers your question =)

  • #3
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i have to do that coding here because when I previewed my post the site keeps kicking it back and saying form tag is detected and could cause security problem for the site and would not let me post. Sorry

    I will try the solution suggested. Thanks

  • #4
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what about page1.aspx?ser=?????????. I have tried different ways and still dont have anything that works. Any thoughts, suggestions? Thanks

  • #5
    New Coder
    Join Date
    Mar 2007
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hmm, oh right ya need to set the url corresponding to whats in the textbox huh?

    you could use javascript, or you could put autopostback="true" on your textbox and add the
    [code]
    Protected Sub textSer_TextChanged(ByVal sender as Object, ByVal e as System.EventArgs) 'or whatever the textchanged event requires, you can probably generate the event with the dropdownlists at the top
    firstbuttn.NavigateUrl = "page1.aspx?ser=" & textSer.Text
    secondbuttn.NavigateUrl = "page1.aspx?ser=" & textSer.Text
    End Sub

    the only drawback to this, is that itll cause a post back. Javascript wouldn't. (Though if you're using AJAX you could use an update panel and make just the specific part of the page you need reload).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •