J
Jonathan
Hi everyone,
I am new to asp.net and here is my problem. I create a UserControl
included in my main file (index.aspx). Depending on witch parameter i
have pass, i "execute" a UserControl part with a SelectCase.
Here's my code:
/***************************
index.aspx
***************************/
<%@ Register TagPrefix="Acme" TagName="Content" Src="Content.ascx" %>
<body>
<form method="post" runat="server">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<a href="?link=mylink1">Text</a>
</td>
</tr>
<tr>
<td>
<a href="?link=mylink2">Text2</a>
</td>
</tr>
<tr>
<td><Acme:Content runat="server"/></td>
</tr>
<tr>
<td>Some text here</td>
</tr>
</table>
</form>
</body>
/***************************
my user control (Content.ascx)
***************************/
<script language="VB">
Sub Register_click( ByVal Sender as Object, ByVal e as
ImageClickEventArgs )
If Page.IsValid
/*execute some code here*/
End If
End Sub
</script>
<table border="0" cellpadding="0" cellspacing="0">
<%select case request.querystring("link")%>
<%case "mylink1"%>
<tr>
<td><asp:textbox id="MyField1" runat="server" /></td>
<td><asp:RequiredFieldValidator ControlToValidate="MyField1"
Display="Dynamic" errormessage="Required!" runat="server" />
</td>
</tr>
<%case "mylink2"%>
<tr>
<td><asp:textbox id="MyField2" runat="server" /></td>
<td>
<asp:RequiredFieldValidator ControlToValidate="MyField2"
Display="Dynamic" errormessage="Required!" runat="server" />
</td>
</tr>
<tr>
<asp:imageButton id="Register"
ImageURL="./Image.gif" onclick="Register_click"
runat="server"></asp:imageButton>
</tr>
<%end select%>
</table>
For example, if i select the hyperlink "Text2", "MyField2" will be shown
with the "Register" button. If i click on it, it seems as if both
FieldValidators are executed because the page won't ever be validated.
Can somebody help me up with that?
Plus, i think my UserControl ain't the real appropriate way of doing what
i am doing (Multiple links on my index.aspx page that change a cells
content). Any other suggestions (ex: include a file like old Asp,
CustomControl, etc.)????
Thanks a lot in advance!
Jonathan
I am new to asp.net and here is my problem. I create a UserControl
included in my main file (index.aspx). Depending on witch parameter i
have pass, i "execute" a UserControl part with a SelectCase.
Here's my code:
/***************************
index.aspx
***************************/
<%@ Register TagPrefix="Acme" TagName="Content" Src="Content.ascx" %>
<body>
<form method="post" runat="server">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<a href="?link=mylink1">Text</a>
</td>
</tr>
<tr>
<td>
<a href="?link=mylink2">Text2</a>
</td>
</tr>
<tr>
<td><Acme:Content runat="server"/></td>
</tr>
<tr>
<td>Some text here</td>
</tr>
</table>
</form>
</body>
/***************************
my user control (Content.ascx)
***************************/
<script language="VB">
Sub Register_click( ByVal Sender as Object, ByVal e as
ImageClickEventArgs )
If Page.IsValid
/*execute some code here*/
End If
End Sub
</script>
<table border="0" cellpadding="0" cellspacing="0">
<%select case request.querystring("link")%>
<%case "mylink1"%>
<tr>
<td><asp:textbox id="MyField1" runat="server" /></td>
<td><asp:RequiredFieldValidator ControlToValidate="MyField1"
Display="Dynamic" errormessage="Required!" runat="server" />
</td>
</tr>
<%case "mylink2"%>
<tr>
<td><asp:textbox id="MyField2" runat="server" /></td>
<td>
<asp:RequiredFieldValidator ControlToValidate="MyField2"
Display="Dynamic" errormessage="Required!" runat="server" />
</td>
</tr>
<tr>
<asp:imageButton id="Register"
ImageURL="./Image.gif" onclick="Register_click"
runat="server"></asp:imageButton>
</tr>
<%end select%>
</table>
For example, if i select the hyperlink "Text2", "MyField2" will be shown
with the "Register" button. If i click on it, it seems as if both
FieldValidators are executed because the page won't ever be validated.
Can somebody help me up with that?
Plus, i think my UserControl ain't the real appropriate way of doing what
i am doing (Multiple links on my index.aspx page that change a cells
content). Any other suggestions (ex: include a file like old Asp,
CustomControl, etc.)????
Thanks a lot in advance!
Jonathan