This is a migrated thread and some comments may be shown as answers.

Open radwindow without navigateurl and call code behind vb

6 Answers 242 Views
Window
This is a migrated thread and some comments may be shown as answers.
Fabio Cirillo
Top achievements
Rank 1
Fabio Cirillo asked on 09 Jan 2013, 10:01 AM
Hi,
i open the radwindow into page without navigaturl. This my code is:
<telerik:RadWindow ID="RadWindowAnteprimaProfile" runat="server" ShowContentDuringLoad="false" Title="Anteprima immagine" Behaviors="None"
Modal="True" Behavior="None" Font-Names="Verdana" Font-Size="Small" IconUrl="/image/iconlogo.png" Width="350px" Height="280px"
MaxHeight="300px" MaxWidth="400px"
ToolTip="Anteprima immagine" VisibleStatusbar="False" Skin="Simple"
ReloadOnShow="True">
<ContentTemplate>
<div class="Divviewimgprifile">
<div class="Divviewimgprifile1">
<table style="width:100%; margin:0px; padding:0px; border:0px">
<tr>
<td style="text-align:center">
<div runat="server" id="imgprofile" class="AnteprimaImgProfile">
</div>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td style="text-align:center; padding-top:10px">
<asp:ImageButton ID="Imgbtnesci_1" runat="server" ImageUrl="~/Image/esci1.png" />
</td>
</tr>
</table>
</div>
</div>
</ContentTemplate>
</telerik:RadWindow>

Now into vb net code i've this code:

    Try
        Dim conString = ConfigurationManager.ConnectionStrings("TrycontactString")
        Dim strConnString As String = conString.ConnectionString
        Using db As New SqlConnection(strConnString)
            db.Open()
            Using sqlcmd As New SqlCommand("Sp_get_imageprofile", db)
                sqlcmd.CommandType = CommandType.StoredProcedure
                sqlcmd.Parameters.AddWithValue("@id", SqlDbType.Int).Value = Session.Item("Idutente")
                Dim _img As String = Replace(sqlcmd.ExecuteScalar, "~", "")
                imgprofile.Attributes("style") = "background-image: url('" + _img + "');"
            End Using
        End Using
    Catch ex As SqlException
        Exit Sub
    Catch ex As Exception
        Exit Sub
    End Try
End If

i would that when i pon the radwindow, start the vb code...How do it?

thanks bye



6 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 09 Jan 2013, 02:46 PM
Hello Fabio,

If you want to have the div in the RadWindow styled you can simply move that code to the Page_Load event.

In case you want to call a server method when the RadWindow shows - you can do that by using JavaScript. The OnClientShow event of the RadWindow is fired when it is shown and there you can write your code to call the server. Examples on initiating different requests are available in this help article.


All the best,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Fabio Cirillo
Top achievements
Rank 1
answered on 09 Jan 2013, 03:03 PM
hello,
thanks for the help, sorry but i dont understand as i can to call a new radwindow into a radwindow. There's this example  http://www.telerik.com/help/aspnet-ajax/window-programming-opening-from-within-dialog.html but can you to see a example code?

Bye
0
Marin Bratanov
Telerik team
answered on 11 Jan 2013, 09:03 AM
Hi Fabio,

The following demo explains the difference between the two modes of RadWindow and how controls on the main page can be accessed when you are using the ContentTemplate: http://demos.telerik.com/aspnet-ajax/window/examples/contenttemplatevsnavigateurl/defaultcs.aspx. Since the contents are on the main page the approach will not differ whether you are using a RadWindow's ContentTemplate or a button inside a simple ASP Panel control. Nevertheless, I am attaching here a simple example of this so you can see it in action.


All the best,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Fabio Cirillo
Top achievements
Rank 1
answered on 11 Jan 2013, 09:22 AM
Good thanks you.

Now i've another problem with radwindow. I load into Div a backgroundimage with javascript and the function javascript call from vbnet

My code aspx is:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function openRadprewimage() {
$find"<%= RadWindowAnteprimaProfile.ClientID %>").show();
}
function closeRadprewimage() {
$find("<%= RadWindowAnteprimaProfile.ClientID %>").close();
}
function StrImage() {
var divimage = $get("<%= imgprofile.ClientID %>");
divimage.style.backgroundImage = "url(Image/image_utenti/1/xx_trinity.jpg)";
openRadprewimage();
}
</script>
</telerik:RadCodeBlock>
<telerik:RadWindow ID="RadWindowAnteprimaProfile" runat="server" ShowContentDuringLoad="false" Title="Anteprima immagine" Behaviors="None"
Modal="True" Behavior="None" Font-Names="Verdana" Font-Size="Small" IconUrl="/image/iconlogo.png" Width="265px" Height="267px"
ToolTip="Anteprima immagine" VisibleStatusbar="False" Skin="Simple" ReloadOnShow="True">
<ContentTemplate>
<div class="Divviewimgprifile">
<div class="Divviewimgprifile1">
<table style="width:100%; margin:0px; padding:0px; border:0px">
<tr>
<td style="text-align:center">
<div runat="server" id="imgprofile" class="AnteprimaImgProfile">
</div>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td style="text-align:center; padding-top:10px">
<asp:ImageButton ID="Imgbtnesci" runat="server" ImageUrl="~/Image/esci1.png" OnClientClick="closeRadprewimage(); return false" />
</td>
</tr>
</table>
</div>
</div>
</ContentTemplate>
</telerik:RadWindow>

and my vbnet code is:

ScriptManager.RegisterStartupScript(Page, Me.Page.GetType(), "image", "Strimage()", True)

the radwindow start but the backgroundimage of the Div not see not load.

Why?









0
Fabio Cirillo
Top achievements
Rank 1
answered on 11 Jan 2013, 11:10 AM
and i've another problem. The your code function but i need that the second radwindow load after a update record into database and i need call the second radwindow without button.....

i call first radwindow:



                function openRaddelete() {
                    $find("<%= RadWindowProfiledelete.ClientID %>").show();
                }
                    function openRadconfirmdelete() {
                        $find("<%= RadWindowconfirmdelete.ClientID %>").show();
                    }
                    function closeRadconfirmdelete() {
                        $find("<%= RadWindowconfirmdelete.ClientID %>").close();
                    }
<asp:Button ID="Button1" Text="open the first" OnClientClick="openRaddelete(); return false;"
<telerik:RadWindow ID="FirstRw" runat="server" Title="First">
    <ContentTemplate>
        <asp:Button ID="Button2" Text="update record"   runat="server" />
    </ContentTemplate>
</telerik:RadWindow>

the button2 start into vbnet this code:

Try
    Dim conString = ConfigurationManager.ConnectionStrings("TrycontactString")
    Dim strConnString As String = conString.ConnectionString
    Using db As New SqlConnection(strConnString)
        db.Open()
        Using sqlcmd As New SqlCommand("Sp_delete_imagecard", db)
            sqlcmd.CommandType = CommandType.StoredProcedure
            sqlcmd.Parameters.AddWithValue("@idutente", SqlDbType.Int).Value = idutente
            sqlcmd.ExecuteNonQuery()
        End Using
    End Using
Catch ex As SqlException
    Exit Sub
Catch ex As Exception
    Exit Sub
End Try

after delete record i need into first radwindow, to load the second radwindow that has this code:

<telerik:RadWindow ID="SecondRw" runat="server" Title="Second">
    <ContentTemplate>
        record deleted!!
        <asp:Button ID="Button3" Text="close radwindow" OnClientClick="closeSecond(); return false;"
    </ContentTemplate>
</telerik:RadWindow>

but if i write after query sql this code: 
 ScriptManager.RegisterStartupScript(Page, Me.GetType, "openwindow", "openRadconfirmdelete(); return false;", True)

dont load second radwindow into first radwindow but load outside radwindow
0
Marin Bratanov
Telerik team
answered on 15 Jan 2013, 12:10 PM
Hello Fabio,

Does the image appear when you place the div outside of the RadWindow?

The first problem I see in the snippet you sent is that the first call to $find() is missing the opening parenthesis, so a JavaScript error will be thrown on the page, which effectively breaks JavaScript execution.

The second problem, that will also cause a JavaScript error is the casing of the StrImage function() - the I is lowercase in the code-behind call while it should match the definition on the page.

The third problem is the timing - the script will, most likely, be executed too early for the script control to be initialized, once again resulting in a JavaScript error. Most likely you will need to use the Sys.Application.Load event as shown here.

Once all these general conditions were met things were working fine with me when I tested your code.

On your second query - the content template of the RadWindow is part of the same page (as explained in the demo I linked in my first reply) so you cannot confine one popup in the other in this case. What I can suggest is taking a look at the RadNotification's Show(newText) method for such messages: http://demos.telerik.com/aspnet-ajax/notification/examples/servershowwithnewtext/defaultvb.aspx.



Greetings,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Window
Asked by
Fabio Cirillo
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Fabio Cirillo
Top achievements
Rank 1
Share this question
or