...

View Full Version : passing variables



tonyappleby36
04-24-2007, 03:07 PM
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.....



<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)....



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>

Krokador
04-24-2007, 05:44 PM
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">



<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 =)

tonyappleby36
04-24-2007, 07:43 PM
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

tonyappleby36
04-25-2007, 11:01 PM
what about page1.aspx?ser=?????????. I have tried different ways and still dont have anything that works. Any thoughts, suggestions? Thanks

Krokador
04-26-2007, 06:24 PM
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).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum