|
seems weird to me but when i try to put a function in a standalone .aspx file i get weird errors
so the file "blah.aspx" starts like:
<%@ Page Language="C#"%>
<%
Response.Write("hellow world");
myFunc();
Response.Write("Bye Bye Cruel World");
bool myFunc()
{
return true;
}
%>
and it won't compile ... says "} expected" and then a bunch of stuff about delegates etc in some randomly named files
anybody got any clue?
thnx
"mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them"
modified on Friday, December 17, 2010 11:27 AM
|
|
|
|
|
They are allowed, but you have to write your methods within a <script runat="server"> tag:
<script runat="server">
bool myFunc()
{
return true;
}
</script>
|
|
|
|
|
Good Day All.
I have two problems , but i will address them in different threads. I have a dropdownlist in a UpdatePanel and on selectedIndex change i am doing something on the server side and the drop-down make the page to flicker. This is the Defination of my page. The dropdown is at the bottom and its bolded
<asp:UpdatePanel ID="UpdateSerials" runat="server">
<ContentTemplate>
<div id ="ParentDiv">
<asp:Panel ID="boxpanel" runat="server">
<table class="style1">
<tr>
<td>
<asp:Label ID="Label24" runat="server" TabIndex="22" Text="Box No:"></asp:Label>
</td>
<td>
<asp:Label ID="lblBoxNumber" runat="server" TabIndex="23" Text="Box Number"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Unit1:"></asp:Label>
<asp:TextBox ID="txtUnitLen1" Width="136px" runat="server" onKeyUp="Jump()" TabIndex="1"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtUnitLen1" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</td>
<td>
<asp:Label ID="Label11" runat="server" Text="Unit11:"></asp:Label>
<asp:TextBox ID="txtUnitLen11" Width="136px" runat="server" onKeyUp="Jump()" TabIndex="10"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator20" runat="server"
ControlToValidate="txtUnitLen11" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="Unit2:"></asp:Label>
<asp:TextBox ID="txtUnitLen2" Width="136px" runat="server" onKeyUp="Jump()" TabIndex="1"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtUnitLen2" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</td>
<td>
<asp:Label ID="Label12" runat="server" Text="Unit12:"></asp:Label>
<asp:TextBox ID="txtUnitLen12" Width="136px" runat="server" onKeyUp="Jump()" TabIndex="11"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator19" runat="server"
ControlToValidate="txtUnitLen12" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="Unit3:"></asp:Label>
<asp:TextBox ID="txtUnitLen3" Width="136px" runat="server" onKeyUp="Jump()" TabIndex="2"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtUnitLen3" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</td>
<td>
<asp:Label ID="Label13" runat="server" Text="Unit13:"></asp:Label>
<asp:TextBox ID="txtUnitLen13" Width="136px" runat="server" onKeyUp="Jump()" TabIndex="12"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator18" runat="server"
ControlToValidate="txtUnitLen13" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label4" runat="server" Text="Unit4:"></asp:Label>
<asp:TextBox ID="txtUnitLen4" Width="136px" runat="server" onKeyUp="Jump()" TabIndex="3"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtUnitLen4" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</td>
<td>
<asp:Label ID="Label14" runat="server" Text="Unit14:"></asp:Label>
<asp:TextBox ID="txtUnitLen14" Width="136px" runat="server" onKeyUp="Jump()" TabIndex="13"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator17" runat="server"
ControlToValidate="txtUnitLen14" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label5" runat="server" Text="Unit5:"></asp:Label>
<asp:TextBox ID="txtUnitLen5" Width="136px" runat="server" onKeyUp="Jump()" TabIndex="4"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="txtUnitLen5" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</td>
<td>
<asp:Label ID="Label15" runat="server" Text="Unit15:"></asp:Label>
<asp:TextBox ID="txtUnitLen15" Width="136px" runat="server" onKeyUp="Jump()" TabIndex="14"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator16" runat="server"
ControlToValidate="txtUnitLen15" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label6" runat="server" Text="Unit6:"></asp:Label>
<asp:TextBox ID="txtUnitLen6" Width="136px" runat="server" onKeyUp="Jump()" TabIndex="5"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
ControlToValidate="txtUnitLen6" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</td>
<td>
<asp:Label ID="Label16" runat="server" Text="Unit16:"></asp:Label>
<asp:TextBox ID="txtUnitLen16" Width="136px" runat="server" onKeyUp="Jump()" TabIndex="15"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator15" runat="server"
ControlToValidate="txtUnitLen16" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label7" runat="server" Text="Unit7:"></asp:Label>
<asp:TextBox ID="txtUnitLen7" Width="136px" runat="server" onKeyUp="Jump()" TabIndex="6"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server"
ControlToValidate="txtUnitLen7" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</td>
<td>
<asp:Label ID="Label17" runat="server" Text="Unit17:"></asp:Label>
<asp:TextBox ID="txtUnitLen17" Width="136px" runat="server" onKeyUp="Jump()" TabIndex="16"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator14" runat="server"
ControlToValidate="txtUnitLen17" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label8" runat="server" Text="Unit8:"></asp:Label>
<asp:TextBox ID="txtUnitLen8" Width="136px" runat="server" onKeyUp="Jump()" TabIndex="7"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server"
ControlToValidate="txtUnitLen8" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</td>
<td>
<asp:Label ID="Label18" runat="server" Text="Unit18:"></asp:Label>
<asp:TextBox ID="txtUnitLen18" Width="136px" runat="server" onKeyUp="Jump()" TabIndex="17"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator13" runat="server"
ControlToValidate="txtUnitLen18" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label9" runat="server" Text="Unit9:"></asp:Label>
<asp:TextBox ID="txtUnitLen9" Width="136px" runat="server" onKeyUp="Jump()" TabIndex="8"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server"
ControlToValidate="txtUnitLen9" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</td>
<td>
<asp:Label ID="Label19" runat="server" Text="Unit19"></asp:Label>
<asp:TextBox ID="txtUnitLen19" runat="server" onKeyUp="Jump()" TabIndex="18"
Width="136px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server"
ControlToValidate="txtUnitLen19" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label10" runat="server" Text="Unit:10"></asp:Label>
<asp:TextBox ID="txtUnitLen10" runat="server" onKeyUp="Jump()" TabIndex="9"
Width="136px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server"
ControlToValidate="txtUnitLen10" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</td>
<td>
<asp:Label ID="Label20" runat="server" Text="Unit:20"></asp:Label>
<asp:TextBox ID="txtUnitLen20" runat="server" AutoPostBack="True"
Width="136px" onKeyUp="Jump()" TabIndex="19"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server"
ControlToValidate="txtUnitLen20" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<table class="style1">
<tr>
<td class="style2" valign="middle">
<asp:Panel ID="Panel1" runat="server">
<asp:Button ID="btnComplete" runat="server" Height="26px"
onclick="btnComplete_Click1" TabIndex="20" Text="Complete" Width="83px" />
<asp:Button ID="btnComplete2" runat="server" CssClass="buttonSubmitHide"
onclick="btnComplete2_Click" Text="Complete" Width="83px" />
</asp:Panel>
<asp:Panel ID="ModalPanel" runat="server" BackColor="Green"
HorizontalAlign="Center" Style="display: none">
<asp:Label ID="lblPanelMessage" runat="server"></asp:Label>
<asp:Button ID="btnCancel" runat="server" Text="Close Me" />
</asp:Panel>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblSerialNumber" runat="server" Text="Serial no length:"></asp:Label>
</td>
</tr>
</table>
</td>
<td valign="top">
<asp:DropDownList ID="ddlAutoText" runat="server"
Height="24px" onselectedindexchanged="ddlAutoText_SelectedIndexChanged"
TabIndex="21" Width="180px" AutoPostBack="True">
<asp:ListItem Value="0">Autonext function disabled.</asp:ListItem>
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
<asp:ListItem Value="5">5</asp:ListItem>
<asp:ListItem Value="6">6</asp:ListItem>
<asp:ListItem Value="7">7</asp:ListItem>
<asp:ListItem Value="8">8</asp:ListItem>
<asp:ListItem Value="9">9</asp:ListItem>
<asp:ListItem Value="10">10</asp:ListItem>
<asp:ListItem Value="11">11</asp:ListItem>
<asp:ListItem Value="12">12</asp:ListItem>
<asp:ListItem Value="13">13</asp:ListItem>
<asp:ListItem Value="14">14</asp:ListItem>
<asp:ListItem Value="15">15</asp:ListItem>
<asp:ListItem Value="16">16</asp:ListItem>
<asp:ListItem Value="17">17</asp:ListItem>
<asp:ListItem Value="18">18</asp:ListItem>
<asp:ListItem Value="19">19</asp:ListItem>
<asp:ListItem Value="20">20</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblMessage" runat="server" ForeColor="Red"
style="font-weight: 700"></asp:Label>
</td>
<td valign="top">
</td>
</tr>
</table>
</asp:Panel>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnComplete" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
as you can see , it is inside the Update Panel , but when i select it flickers. and Below is the code that set the max length of the textboxes
protected void ddlAutoText_SelectedIndexChanged(object sender, EventArgs e)
{
int MaxLength = Convert.ToInt32(ddlAutoText.SelectedValue);
txtUnitLen2.MaxLength = MaxLength;
txtUnitLen3.MaxLength = MaxLength;
txtUnitLen4.MaxLength = MaxLength;
txtUnitLen5.MaxLength = MaxLength;
txtUnitLen6.MaxLength = MaxLength;
txtUnitLen7.MaxLength = MaxLength;
txtUnitLen8.MaxLength = MaxLength;
txtUnitLen9.MaxLength = MaxLength;
txtUnitLen10.MaxLength = MaxLength;
txtUnitLen11.MaxLength = MaxLength;
txtUnitLen12.MaxLength = MaxLength;
txtUnitLen13.MaxLength = MaxLength;
txtUnitLen14.MaxLength = MaxLength;
txtUnitLen15.MaxLength = MaxLength;
txtUnitLen16.MaxLength = MaxLength;
txtUnitLen17.MaxLength = MaxLength;
txtUnitLen18.MaxLength = MaxLength;
txtUnitLen19.MaxLength = MaxLength;
txtUnitLen20.MaxLength = MaxLength;
txtUnitLen1.MaxLength = MaxLength;
}
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Is it browser specific or does it happen with all the browsers?
..Go Green..
|
|
|
|
|
It happens in all Browsers
Thanks for your reply.
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
I have seen this behavior but that's IE6 specific.
Let me check if I could replicate it for all browsers. I will get back to you if I find something relevant.
..Go Green..
|
|
|
|
|
|
Thanks i will look at the Link
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
i decided that i should handle the SelectedIndexchange event on the client side. Now its fine it does not Flicker. I even removed the Autopostback and set it to false.
thanks for your time.
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
I had a similar idea when I saw your code but then I thought that the code you have given may be a part of actual thing that you are implementing. It may require a post-back for server side processing. So I didn't suggest you the JavaScript way of doing this.
Anyways, glad to hear that you finally found a workaround solution.
Vuyiswa Maseko wrote: thanks for your time.
You are welcome.
..Go Green..
|
|
|
|
|
Hai all,
I want to display confirmation message box in Asp.net code behind (C#).
When I save the record i am doing some validations , in the validation function i need to display confirmation message with "yes"
or "no" , if "yes" the save process should be done and if "no" save process should not be proceed .
I have used Page.ClientScript.RegisterStartupScript() ,but it is not working.
I have also tried btnSave.Attributes.Add("onclick", "return confirm()"); but the confirmation message is opened before save .
I need only at the time of validation .
Please Help me.
Thank u
modified on Friday, December 17, 2010 12:42 AM
|
|
|
|
|
<asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" OnClientClick="return confirm('Do you really want to save?');" />
Just use this in your button and I am sure it will work definitely.
|
|
|
|
|
Thanks for the reply
I no need to call the function in onClientClick() , that will work fine .
I need to call the script function only at the server side validation because the confirmation message should work based on the
server side validation.
Thank you
|
|
|
|
|
Can you please show us Page.ClientScript.RegisterStartupScript() , what you've written inside ?
|
|
|
|
|
This is my coding
protected void btnSave_Click(object sender, Infragistics.WebUI.WebDataInput.ButtonEventArgs e)
{
try
{
if (!fnValidate()) return;
else
{
save();
}
}
catch (Exception ex)
{
throw(ex);
}
}
bool fnValidate()
{
Page.ClientScript.RegisterStartupScript(this.GetType(),
"ClientScript", "");
}
Client side function
function confirmUpdate()
{
var agree = vbConfirm(Are you sure do you want to continue ?');
if (agree == true)
{
return true;
}
else
{
return false;
}
}
|
|
|
|
|
priyagee wrote: Page.ClientScript.RegisterStartupScript(this.GetType(),
"ClientScript", "confirmUpdate();</b></blockquote>
See that, you haven't closed with <code></script></code>.
<div class="signature">Regards,
Hiren.
<div class="callout align-center" style="margin:1px"><b><font color="red">My Recent Article:</font></b> - <a href="http://www.codeproject.com/KB/aspnet/Postback_raising_control.aspx">Way to know which control have raised PostBack</a><br /><b><font color="red">My Recent Tip/Trick:</font></b> - <a href="http://www.codeproject.com/Tips/136704/Remove-all-the-HTML-tags-and-display-a-plain-text-.aspx">Remove HTML Tag, get plain Text</a></div></div>
|
|
|
|
|
Ajax Modal Pop Up extender has a ".Show" property... here[^] got some help! It's in your imagination the way you need to use the modal!
|
|
|
|
|
Hi,
I tried running the following linq to sql query in linq to entity
var req = dbContext.Requisitions.First(r=>r.ID==new Guid(Request["ReqID"]));
I got the following error "Only parameterless constructors and initializers are supported in LINQ to Entities." Any ideas how to go about this?
Thanks
|
|
|
|
|
Got a work around, did something like this
Guid ReqID = new Guid(Request["ReqID"]);
var req = dbContext.Requisitions.First(r => r.ID == ReqID);
|
|
|
|
|
I need your help guys ...
I have a Listview which contains application names.Multiple items can be selected in it.Now depending on the number of selections made,I have to list all their related testcases in seperate listviews(1 listview for each selection made).
Also the testcases should be come in the listviews in a checkbox format.
So I feel depending on the no. of selections made ,I need to create listviews at runtime(dynamic) and then fill them up with testcases which need to be in a checkbox format.
But I am stuck as to how to create dynamic listview and fill it up.I am not a very experienced coder.
Req doc is like this
· Once the user selects an application a table with all the test cases associated with that application gets displayed.
· If the user checks the check box against the application name then all test cases will get selected.
· Else he can choose specific test cases by checking the check boxes beside the test cases.
My code for 1 listbox selection is as follows and working f9.But this is a satic listview as only one item can be selected.Now the requirement is for multiselect so the situation has changed and I cant use this approach.
Aspx page contains following code:
<asp:Panel runat="server">
<asp:CheckBox runat="server" AutoPostBack="True" Text="Select All" Visible="false"/>
<asp:ListView runat="server" >
<LayoutTemplate>
<table border="1" >
<tr runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr id="Tr1" style="font-size: small">
<td>
<asp:CheckBox runat="server" Text='<%# Eval("TestCaseName") %>' Value='<%# Eval("TestCaseID") %>'>
</asp:CheckBox>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
</asp:Panel>
Code Behind is as follows:
protected void lbSelectApplications_SelectedIndexChanged(object sender, EventArgs e)
{
int cobrandId = Convert.ToInt32(ddlSelectCobrand.SelectedValue);
int appid = Convert.ToInt32(lbSelectApplications.SelectedValue);
if (appid != -1 && cobrandId != -1)
{
BusinessLogicLayer.BusinessLogic obj = new BusinessLogicLayer.BusinessLogic();
testcasedataset= obj.GetActiveTestcasesForSpecificCObrandedApplication(appid, cobrandId);
listView2.DataSource = testcasedataset.Tables[0];
listView2.DataBind();
listView2.Visible = true;
chkall.Text = lbSelectApplications.SelectedItem.Text.ToString();
chkall.Visible = true;
for (int i = 0; i < testcases.Tables.Count; i++)
{
ListView lv = new ListView();
//here dynamic creation of listview code should go
}
protected void chkall_CheckedChanged(object sender, EventArgs e)
{
for (int i = 0; i < listView2.Items.Count; i++)
{
CheckBox chk = (CheckBox)listView2.Items[i].FindControl("chkTest");
if (chkall.Checked == true)
{
chk.Checked = true;
}
else
{
chk.Checked = false;
}
}
}
}
Pls I need ur help.Please advise how to go about itand if you have a better alternative do let me know.
thanks
|
|
|
|
|
Always wrap your code in <pre></pre> to get better response.
|
|
|
|
|
Hi All,
A few months ago I remember reading about a new version of IIS that was a 'half way house' between full blown IIS and development server but I cannot for the life of me remember the name or soemthing to google with.
Anyone have any links?
Cheers,
|
|
|
|
|
|
Doh! (>_<) ! Not exactly cryptic is it!
Much appreciated Scott.
|
|
|
|
|
Hi,
I have this webapplication with some webservices on it. I'd like my client software to be abble to access them, so far so good. My question(s) is(are):
1) Do I have to add the webreference to the client point to each server it can access?
2) Is there a better way to change the URL for the webservice reference, so the client can be configured to access a new server anytime?
Thanks,
Dirso
|
|
|
|