Affiliate Marketing
Forum Search


Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 14-04-06
accelerator's Avatar
Online shopping rocks!
 
Join Date: Nov 2004
Location: England
Posts: 1,314
Thanks: 8
Thanked 29 Times in 26 Posts
accelerator is an unknown quantity at this point
  Help! Setting property value in vb.net user control

Hi All

If there are any vb.net coders here I could really use some help on what should be something simple but is currently driving me crazy.


I have a .ascx User Control which I am incorporating into a .aspx page.

In the .ascx user control file, I have an SQL statement, where I want to make use of a variable called KeyphraseText. It looks like this:


<%

.....

Dim Sql As String = "SELECT ..... WHERE KeyphraseText LIKE '" & KeyphraseText & "' AND ...... ;"

.....

%>

All I am trying to achieve is to set this variable from a line in my .aspx file. Sounds easy right? Well, I seem to be struggling. So far, I have been advised that the best way to achieve this is to add a vb.net property to the .ascx file, which I have done as follows:

<script runat=server>


Public KeyphraseText As String

Public Property KeyphraseTextAssignment() As String


Get

Return KeyphraseText

End Get


Set(ByVal Value As String)

KeyphraseText = Value

End Set


End Property


</script>


I think the syntax for my property statement is correct, so all I need to do now is set the property value from my .aspx file. FYI the id of the user control is merchantsfromfilename, and I have the following user control statement in my .aspx file:

<navito:merchantsfromfilename id="merchantsfromfilename" runat="server" />

The .aspx file does actually make use of a code behind page, so into that I have added my attempted assignment of the property in my user control as follows:

merchantsfromfilename.KeyphraseTextAssignment = "mobile phones"

Currently this line is causing the compiler error:

Compiler Error Message: BC30188: Declaration expected.


Can people please come to the assistance of a very frustrated coder. Bearing in mind my simple objective, can anyone shed any light on this problem?



Thanks

Accelerator
__________________
WebRef.eu - Web Development Resources for the Online Entrepreneur
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 14-04-06
Registered User
 
Join Date: Aug 2003
Location: Cheshire
Posts: 251
Thanks: 0
Thanked 0 Times in 0 Posts
HeresJonny is an unknown quantity at this point
You shouldn't have <% or %> tags appearing in any of your .NET code at all - these tags apply to "old" ASP scripts.

Can you give more of an idea of what you are trying to achieve, I may be able to offer some more help !

Jon
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 15-04-06
accelerator's Avatar
Online shopping rocks!
 
Join Date: Nov 2004
Location: England
Posts: 1,314
Thanks: 8
Thanked 29 Times in 26 Posts
accelerator is an unknown quantity at this point
Jon

The fundamental thing that I am trying to achieve is to use vb.net to assign a variable in a .aspx page (or it's code behind page), that can then be recognised by a .ascx user control being incorporated on that .aspx page.

So far I have tried declaring a Public variable in the .aspx page, but then I get a declaration required from the .ascx user control.

Now I'm trying to add a property statement to the .ascx user control (which I think I have right) and add property assignment code to the .aspx page (which I'm still not sure of).

Any thoughts?

Thanks

Accelerator
__________________
WebRef.eu - Web Development Resources for the Online Entrepreneur
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 17-04-06
Registered User
 
Join Date: Sep 2003
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
monkeyboy is an unknown quantity at this point
If this is the tag in your aspx page ...
Quote:
<navito:merchantsfromfilename id="merchantsfromfilename" runat="server" />
... and the property is called KeyphraseTextAssignment then all you should need to do is set the property inside this tag.

So, assuming I haven't misunderstood what you are trying to do, your tag becomes

Code:
<navito:merchantsfromfilename id="merchantsfromfilename" runat="server" KeyphraseTextAssignment="mobile phones" />
Incidently if you don't need to read the value of KeyphraseTextAssignment from the control I'd suggest changing the public property to WriteOnly.

Code:
Public WriteOnly Property KeyphraseTextAssignment() As String
then delete the get code.
__________________
Prezzybox.com home of the gift wizard
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #5 (permalink)  
Old 17-04-06
Registered User
 
Join Date: Sep 2003
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
monkeyboy is an unknown quantity at this point
Quote:
Originally Posted by accelerator
The fundamental thing that I am trying to achieve is to use vb.net to assign a variable in a .aspx page (or it's code behind page), that can then be recognised by a .ascx user control being incorporated on that .aspx page.
I'm not sure if my earlier post fits the bill for you. My earlier post works if you know when the page is being designed what the value of KeyphraseTextAssignment will be.

When you say assign a variable do you mean that you want to set the value at runtime? If so there are a couple of ways of doing that. I'd favour adding a placeholder into the aspx page, create the usercontrol in your code file set its property then add the control to the placeholder. It sounds more complicated that it is, if you want to do that let me know and I'll post some code.
__________________
Prezzybox.com home of the gift wizard
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 22-04-06
accelerator's Avatar
Online shopping rocks!
 
Join Date: Nov 2004
Location: England
Posts: 1,314
Thanks: 8
Thanked 29 Times in 26 Posts
accelerator is an unknown quantity at this point
Monkeyboy

A big thank you, I had to make the property assignment within the tag, as you had suggested. Your help was much appreciated.

All the best

Accelerator
__________________
WebRef.eu - Web Development Resources for the Online Entrepreneur
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql user area chrissy The Affiliate Marketing Lounge 1 16-01-06 05:11 PM
New Affiliate Control Area paidonresults Paid On Results 1 29-08-05 07:00 PM
Improved Affiliate Control Area paidonresults Paid On Results 6 29-10-04 09:36 PM
New Merchant - The Property Investor Show rufus Affiliate Future 0 31-08-04 02:33 PM


Affiliate Marketing RSS Feeds - Contact Us - Affiliate Marketing - Archive - Privacy Statement - Top

Content Relevant URLs by vBSEO 3.2.0 RC7