Monday, January 18, 2010

Access and set properties for controls on main page inside an iframe page using vb.net 1.*?

Hi





I have a asp.net page (index.aspx) which has an inframe in which I opened another page (questions.aspx). If a button on the questions page is clicked, I want to change the url of a server image control that is on the main page. How do I do this and how do I in general, access and set properties of main form controls from a page in the in-frame?





Thanking you in advance.





ZabronAccess and set properties for controls on main page inside an iframe page using vb.net 1.*?
If you want to use .NET functionality, you'll need to either redraw the entire main page, including the iframe or seriously hack the client side controls. If you are using a tamper-proof viewstate, the hacking option isn't possible. I wouldn't recommend that anyway, as an update to the .NET runtime might invalidate your hack.





If you don't mind doing this on the client and not affecting the server side view of the controls, you can use CSS and javascript to locate the main frame (the ';top'; object) and change the image, for example:





top.myImage.src = ';whatever.jpg';;





Another option is to write a custom control in place of the iframe. This option is pretty complicated and you should look in the documentation for writing a custom control to learn how to do basic custom controls. A last option would be to use an included page instead of an iframe, this would put all the contorls on the same level (i.e. no iframe) which makes it easier for .NET controls to communicate with each other on th client side and still stay synchronized with the server side.

In vb.net (express edition), why the variable declarations for the form controls is not shown in the code?

What I mean for example is, why when you create a button from the toolbox, the button has a variable but is not reflected in the code?





I mean, if you create a button with name ';button1'; and in the code you type ';dim button1 as string';, you get message that is already declared but you do not see the declaration in the code.





Would be interesting for me to see answers for this.


Thanks in advance.In vb.net (express edition), why the variable declarations for the form controls is not shown in the code?
Well, I have the standard edition of VS2005, If your form is form1.vb, you also have a file form1.designer.vb. The button is there.In vb.net (express edition), why the variable declarations for the form controls is not shown in the code?
I rarely touch VB but this is something I stumbled upon before: rename the files to .txt or somehow read it as text and you'll see the entire codes; programming GUIs within same code are possible beginning Java and C#, VB and .Net version of it Microsoft would have you think there is no code required for its GUI portion.
  • topical cream
  • VB.net raise events, calling other forms controls?

    Hi, I am struggling to adapt to vb.net.


    I need to know how to call another forms control from another form





    e.g. if i was on form 2 and clicked a control, and I wanted to call cmdbtn1 on form1, what would I write, like in vb6 this was just 'call form1.cmdbtn1_click '


    But every time I try anything like this it says: 'use raise events instead , not a member of windows.forms.form2'





    I really need help on this so I would very much appreciate it, thanks.VB.net raise events, calling other forms controls?
    You could put whatever you want to do in cmdbtn1_click in a class. Then you can access that function from both forms. If you need to access controls on the form then you can just pass the form to the function or create an overrideable function.





    EG:





    Public Function Overrides DoSomething(frm1 as form)


    End Function





    Or try





    Raise Events form1.cmdbtn1_click





    hth

    VB.NET, one event for multiple controls?

    I came across an example that looks like this:





    Public Sub OnClockTick2(ByVal sender As Object, ByVal e As


    EventArgs) Handles MyFirstButton.Click, MySecondButton.Click


    Console.WriteLine(';Received a click event of first or second button';)


    End Sub





    which gives me an idea of what I am trying to do. I have a form with multiple textboxes, and I want to do the same thing for each of those textboxes when text is changed in any of them. My question is, however, how do I determine which textbox was changed? Would it have something to do with ';sender'; ?





    thanks!!VB.NET, one event for multiple controls?
    sender is an Object.


    All Objects have an Equals() method for reference comparison.





    Compare sender to MyFirstButton with a simple if..else statement.

    VB.NET, one event for multiple controls?

    I came across an example that looks like this:





    Public Sub OnClockTick2(ByVal sender As Object, ByVal e As


    EventArgs) Handles MyFirstButton.Click, MySecondButton.Click


    Console.WriteLine(';Received a click event of first or second button';)


    End Sub





    which gives me an idea of what I am trying to do. I have a form with multiple textboxes, and I want to do the same thing for each of those textboxes when text is changed in any of them. My question is, however, how do I determine which textbox was changed? Would it have something to do with ';sender'; ?





    thanks!!VB.NET, one event for multiple controls?
    sender is an Object.


    All Objects have an Equals() method for reference comparison.





    Compare sender to MyFirstButton with a simple if..else statement.

    Is it posibble to add controls dynamically in Visula studio VB.net? how?

    uh, what your talking about... you mean programmaticaly, you find the control you want you make a new instance of it and then you it to your form like so...





    yourcontrolhere As New ListView()


    Form1.Controls.Add(yourcontrolhere)Is it posibble to add controls dynamically in Visula studio VB.net? how?
    Yes, and I'm assuming that you're doing a WinForms application.





    Use the Add method of the Controls collection object of your current form, for example:





    Dim txtName as New TextBox();


    'you can set properties for this control too


    ...





    Me.Controls.Add(txtName);Is it posibble to add controls dynamically in Visula studio VB.net? how?
    Yes you can surely do this. Following is a method which adds a button (for example) to your form dynamically. When you will call this method, this will add a button to your form. You can add other controls likewise.





    Private Sub CreatButton()


    Dim btnYes As System.Windows.Forms.Button


    ' Create control


    btnYes = New System.Windows.Forms.Button()


    ' Set button properties


    btnYes.Name = ';ButtonYes';


    btnYes.Size = New System.Drawing.Size(70, 30)


    btnYes.Location = New System.Drawing.Point(300, 30)


    btn.TabIndex = 1


    btnYes.Text = ';YES';


    ' add to the parent form's controls collection


    Me.Controls.Add(btnYes)


    End Sub





    Hope that answers the question

    How to change the place of controls in a form of vb.net?

    you should view your form in Design view and change the controls' places with your mouse! is it so hard, or I didn't understand?!