Click here to Skip to main content
15,890,123 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionProblem when loading an aspx page from ascx Pin
tiran_kaskas29-Jun-09 3:05
tiran_kaskas29-Jun-09 3:05 
AnswerRe: Problem when loading an aspx page from ascx Pin
DoctorMick29-Jun-09 3:13
DoctorMick29-Jun-09 3:13 
AnswerRe: Problem when loading an aspx page from ascx Pin
Muhammad Gouda29-Jun-09 3:23
Muhammad Gouda29-Jun-09 3:23 
GeneralRe: Problem when loading an aspx page from ascx Pin
tiran_kaskas29-Jun-09 3:26
tiran_kaskas29-Jun-09 3:26 
GeneralRe: Problem when loading an aspx page from ascx Pin
tiran_kaskas29-Jun-09 3:41
tiran_kaskas29-Jun-09 3:41 
QuestionRe: Problem when loading an aspx page from ascx Pin
Muhammad Gouda29-Jun-09 4:13
Muhammad Gouda29-Jun-09 4:13 
AnswerRe: Problem when loading an aspx page from ascx Pin
tiran_kaskas29-Jun-09 4:27
tiran_kaskas29-Jun-09 4:27 
GeneralRe: Problem when loading an aspx page from ascx Pin
tiran_kaskas29-Jun-09 5:03
tiran_kaskas29-Jun-09 5:03 
Following is my aspx file:

<br />
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebServer.aspx.cs" Inherits="conversion.WebServer" %><br />
<br />
<%@ Register src="SocketConnection.ascx" tagname="SocketConnection" tagprefix="uc1" %><br />
<br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br />
<br />
<html xmlns="http://www.w3.org/1999/xhtml" ><br />
<head runat="server"><br />
    <title>Socket Connection Test Page</title><br />
</head><br />
<body><br />
    <form id="form1" runat="server"><br />
    <div><br />
    <br />
        <uc1:SocketConnection ID="SocketConnection1" runat="server" /><br />
    <br />
    </div><br />
    </form><br />
</body><br />
</html><br />


Following is my ascx file:

<br />
<br />
using System;<br />
using System.Collections;<br />
using System.Configuration;<br />
using System.Data;<br />
using System.Linq;<br />
using System.Web;<br />
using System.Web.Security;<br />
using System.Web.UI;<br />
using System.Web.UI.HtmlControls;<br />
using System.Web.UI.WebControls;<br />
using System.Web.UI.WebControls.WebParts;<br />
using System.Xml.Linq;<br />
using System.Net;<br />
using System.Net.Sockets;<br />
using System.Collections.Generic;<br />
<br />
namespace conversion<br />
{<br />
    public partial class SocketConnection : System.Web.UI.UserControl<br />
    {<br />
        DataTable myDataTable = null;<br />
        protected void Page_Load(object sender, EventArgs e)<br />
        {<br />
            if (!IsPostBack)<br />
            {<br />
                myDataTable = new DataTable();<br />
            }<br />
        }<br />
<br />
        public void Apply_Click(object sender, EventArgs e)<br />
        {<br />
            try<br />
            {<br />
                Response.Redirect("SocketConnectionListPage.aspx?protocol=" + ProtocolDropDownList.Text +<br />
                                "&port=" + PortTextBox.Text +<br />
                                "&keepalive=" + KeepAliveRadioButtonList.SelectedValue +<br />
                                "&s_timeout=" + SendTimeoutTextBox.Text +<br />
                                "&r_timeout=" + ReceiveTimeoutTextBox.Text +<br />
                                "&s_b_size=" + SendBufferSizeTextBox.Text +<br />
                                "&r_b_size=" + ReceiveBufferSizeTextBox.Text +<br />
                                "&nagle=" + NagleRadioButtonList.SelectedValue +<br />
                                "&ttl=" + TtlTextBox.Text +<br />
                                "&dontfrag=" + DontFragmentButtonList.SelectedValue +<br />
                                "&broadcast=" + BroadcastButtonList.SelectedValue +<br />
                                "&multicast=" + MulticastRadioButtonList.SelectedValue);<br />
<br />
            }<br />
            catch (SocketException se)<br />
            {<br />
                System.Diagnostics.Debugger.Log(0, "1", se.Message);<br />
            }<br />
        }<br />
<br />
<br />
        protected void ProtocolDropDownList_SelectedIndexChanged(object sender, EventArgs e)<br />
        {<br />
            if (ProtocolDropDownList.Text.Equals("TCP"))<br />
            {<br />
                KeepAliveRadioButtonList.Enabled = true;<br />
                NagleRadioButtonList.Enabled = true;<br />
                MulticastRadioButtonList.Enabled = false;<br />
                BroadcastButtonList.Enabled = false;<br />
                DontFragmentButtonList.Enabled = false;<br />
                TtlTextBox.Enabled = false;<br />
            }<br />
            else<br />
            {<br />
                KeepAliveRadioButtonList.Enabled = false;<br />
                NagleRadioButtonList.Enabled = false;<br />
                MulticastRadioButtonList.Enabled = true;<br />
                BroadcastButtonList.Enabled = true;<br />
                DontFragmentButtonList.Enabled = true;<br />
                TtlTextBox.Enabled = true;<br />
            }<br />
        }<br />
<br />
        protected void Reset_Click(object sender, EventArgs e)<br />
        {<br />
            KeepAliveRadioButtonList.Enabled = true;<br />
            NagleRadioButtonList.Enabled = true;<br />
            MulticastRadioButtonList.Enabled = false;<br />
            BroadcastButtonList.Enabled = false;<br />
            DontFragmentButtonList.Enabled = false;<br />
            TtlTextBox.Enabled = false;<br />
<br />
            KeepAliveRadioButtonList.SelectedValue = "false";<br />
            NagleRadioButtonList.SelectedValue = "true";<br />
<br />
            ProtocolDropDownList.SelectedValue = "TCP";<br />
            PortTextBox.Text = "";<br />
            ReceiveBufferSizeTextBox.Text = "";<br />
            ReceiveTimeoutTextBox.Text = "";<br />
            SendBufferSizeTextBox.Text = "";<br />
            SendTimeoutTextBox.Text = "";<br />
        }<br />
    }<br />
}<br />


Now, in the ascx I put myDataTable variable for stub purposes. I use it to determine if a new SocketConnection user control is created.
It seems like the first time the page is loaded, I see a SocketConnection instance being created.
Then, if you click whatever button in that page, you see another instance of SocketConnection being created (as myDataTable is null).


I need to keep some information, like socket connection objects, in the user control class to be able to show a list of clients currently connected to this server and the messages exchange.

Thanks for your help.
GeneralRe: Problem when loading an aspx page from ascx Pin
DoctorMick29-Jun-09 5:24
DoctorMick29-Jun-09 5:24 
GeneralRe: Problem when loading an aspx page from ascx Pin
tiran_kaskas29-Jun-09 5:27
tiran_kaskas29-Jun-09 5:27 
GeneralRe: Problem when loading an aspx page from ascx Pin
Muhammad Gouda29-Jun-09 20:46
Muhammad Gouda29-Jun-09 20:46 
QuestionQuerying carriage return fields Pin
eyeseetee29-Jun-09 2:57
eyeseetee29-Jun-09 2:57 
AnswerRe: Querying carriage return fields Pin
Niladri_Biswas29-Jun-09 6:08
Niladri_Biswas29-Jun-09 6:08 
Questionautomating microsoft word file using vb.net Pin
trimandir prajapati29-Jun-09 1:27
trimandir prajapati29-Jun-09 1:27 
AnswerRe: automating microsoft word file using vb.net Pin
Manas Bhardwaj29-Jun-09 1:37
professionalManas Bhardwaj29-Jun-09 1:37 
QuestionUsing SQL Search in c# page - problem with fields with ' ' in them Pin
eyeseetee29-Jun-09 1:21
eyeseetee29-Jun-09 1:21 
AnswerRe: Using SQL Search in c# page - problem with fields with ' ' in them Pin
SeMartens29-Jun-09 1:55
SeMartens29-Jun-09 1:55 
AnswerRe: Using SQL Search in c# page - problem with fields with ' ' in them Pin
DoctorMick29-Jun-09 2:02
DoctorMick29-Jun-09 2:02 
GeneralRe: Using SQL Search in c# page - problem with fields with ' ' in them [modified] Pin
eyeseetee29-Jun-09 2:20
eyeseetee29-Jun-09 2:20 
AnswerRe: Using SQL Search in c# page - problem with fields with ' ' in them Pin
SeMartens29-Jun-09 2:13
SeMartens29-Jun-09 2:13 
AnswerRe: Using SQL Search in c# page - problem with fields with ' ' in them Pin
Niladri_Biswas29-Jun-09 6:20
Niladri_Biswas29-Jun-09 6:20 
Questioncan't send mail with attachment file,that is from database Pin
pujafaldu29-Jun-09 0:39
pujafaldu29-Jun-09 0:39 
AnswerRe: can't send mail with attachment file,that is from database Pin
Manas Bhardwaj29-Jun-09 0:45
professionalManas Bhardwaj29-Jun-09 0:45 
GeneralRe: can't send mail with attachment file,that is from database Pin
pujafaldu29-Jun-09 1:27
pujafaldu29-Jun-09 1:27 
GeneralRe: can't send mail with attachment file,that is from database Pin
N a v a n e e t h29-Jun-09 1:37
N a v a n e e t h29-Jun-09 1:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.