Welcome Guest Search | Active Topics | Sign In | Register

How do I access the initdata in a dialog Options
paulmcp
Posted: Tuesday, November 27, 2007 4:39:41 AM
Rank: Newbie
Groups: Member

Joined: 11/13/2007
Posts: 3
I have the following Javascript that calls my dialog

javascript:eo_GetObject('Dialog1').show(true, 'caption', 'id=1234567')

I have a submit button on the dialog that calls vb code behind and that works fine

How do I access the id=1234567 information I passed as the parameter in vb so I can use this information in my code behind?

Thanks
eo_support
Posted: Tuesday, November 27, 2007 5:56:31 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

initdata is passed as the second parameter of ClientSideOnInitDialog hanlder:

http://www.essentialobjects.com/ViewDoc.aspx?t=EO.Web.Dialog.ClientSideOnInitDialog.html

More information on how to use client side handler:

http://www.essentialobjects.com/ViewDoc.aspx?t=clientapi_howto.html

If you want to use initdata at other place, you can either store it in a global variable or as a member of the dialog itself. For example:

eo_GetObject('Dialog1').initData = 'id=1234567';

Thanks
paulmcp
Posted: Tuesday, November 27, 2007 7:16:57 AM
Rank: Newbie
Groups: Member

Joined: 11/13/2007
Posts: 3
I don't understand your answer. I looked at the links and there are no code examples just description.

I don't have any experience with javascript so I have no idea how to pass the value to a form field or to the asp.net handlers.
Could you please post an example of how I can do this so I can use the id data in my vb codebehind.

Thank You
eo_support
Posted: Tuesday, November 27, 2007 7:39:23 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

initData is primary for ClientSideOnInitDialog event handler. As the name suggested, it's a client side event, so it has nothing to do with vb code behind. If you would like to do something with code behind, your page must go back to the server first (remember your code behind is server side code, and it must run on the server side!):

Code: HTML/ASPX
<eo:Dialog runat="server" id="Dialog1">
       .......
    </eo:Dialog>
</eo:CallbackPanel> 

<asp:Button runat="server" id="Button1" 
Text="Show Dialog" OnClick="Button1_Click">


Code: Visual Basic.NET
Private Sub Button1_Click(sender As Object, e As System.EventArgs)

     'Do whatever you want to do
     .....


     'Display the dialog
     Dialog1.InitiaState = EO.Web.DialogState.Visible

End Sub


Obviously that will cause the whole page to be refreshed when you click Button1. You can easily get around this with a CallbackPanel. For more details, please refer to CallbackPanel documentations.

Hope this makes sense to you.

Thanks
paulmcp
Posted: Tuesday, November 27, 2007 8:21:50 AM
Rank: Newbie
Groups: Member

Joined: 11/13/2007
Posts: 3
Let me rephrase the question so you understand what I want to do.
I want to put 10 hyperlinks on a page that pass a stock symbol to the dialog using the initparameter.
The user enters a number and presses OK.
The dialog posts data to the server and needs to have the stock symbol from one of the 10 hyperlinks passed to the server along with the post.
How can I get the javascript to pass the symbol to the dialog and then have the dialog pass the symbol to the server when the ok button is pressed on the dialog?

Thanks in Advance
eo_support
Posted: Tuesday, November 27, 2007 8:41:54 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
paulmcp wrote:
Let me rephrase the question so you understand what I want to do.
I want to put 10 hyperlinks on a page that pass a stock symbol to the dialog using the initparameter.

For this part you will need to use JavaScript. If you are not familiar with JavaScript, then forget about init data. Some basic JavaScript will do:


Code: HTML/ASPX
<eo:Dialog runat="server" id="Dialog1">
    <ContentTemplate>
        <div id="symbolDiv">stock symbol goes here</div>
    </ContentTemplate>
</eo:Dialog>
<a href="javascript:ShowDialog('1234567');">show dialog</a>


Code: JavaScript
function showDialog(symbol)
{
    var div = document.getElementById("symbolDiv");
    div.innerHTML = symbol;

    eo_GetObject("Dialog1").show(true);
}


paulmcp wrote:

The user enters a number and presses OK.

For this part you just put an OK button in the dialog and handle the button's click on the server side.


paulmcp wrote:

The dialog posts data to the server and needs to have the stock symbol from one of the 10 hyperlinks passed to the server along with the post.
How can I get the javascript to pass the symbol to the dialog and then have the dialog pass the symbol to the server when the ok button is pressed on the dialog?


The dialog does not help you to pass anything to the server --- so as for how to pass the data to the server would be totally up to you. The easiest way for you is to put a hidden TextBox in the form and then set the textbox's value property on the client side:

Code: HTML/ASPX
<asp:TextBox runat="server" ID="TextBox1" style="display:none" />


Store value to the textbox on the client side:

Code: JavaScript
document.getElementById("TextBox1").value = "abc";


Access value on the server side

Code: Visual Basic.NET
If TextBox1.Value = "abc" Then
    ....
End If


Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.