<asp:PlaceHolder> is not showing on iphone - c#

I have a code in my master page that I used placeholder to show and hide 2 different parts.It is completely works fine in all the Browsers, but it is not working on Iphone Even it is working on Android.
this is my code:
<div class="actions">
<asp:PlaceHolder ID="phLogout" runat="server">
<input TYPE="button" VALUE="Log Out" class="Button Orange" onclick="window.location.href = 'Logout.aspx'">
</asp:PlaceHolder>
<asp:PlaceHolder ID="phLogin" runat="server">
<p class="Title">Current users sign in:</p>
<asp:TextBox runat="server" ID="username" holder="Username"></asp:TextBox>
<asp:TextBox runat="server" ID="password" holder="Password" TextMode="Password"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Log In" class="Button Orange" OnClick="btn_login_Click" ></asp:Button>
<p class="Forgot">Forgot password?</p>
</asp:PlaceHolder>
</div>
I just found out that this part is not showing in the iphone with all the content inside the .
what I can use instead of tag?
I tried but all the styling gets off. Is the only tag replacing this so I may work more on style sheet or you are suggesting something else? Or even if the reason for not showing is the ?

I believe the "holder" attribute in your textboxes should be "placeholder" instead.

Related

CausesValidation=true not working

I have used a Requiredfieldvalidator to validate a text field however when I click on button the page gets posted back even if validation fails. What am i doing wrong? Below is my code.
<div id="addFactDiv" style="display:none;">
<asp:TextBox ID="inputFact" Height="50px" Width="100%" runat="server" TextMode="MultiLine" placeholder="Enter a fact"></asp:TextBox>
<asp:requiredfieldvalidator CssClass="validator" Display="Dynamic" ID="Requiredfieldvalidator5" ControlToValidate="inputFact" ValidationGroup="ValidateFact" ErrorMessage="Please Enter a fact" runat="server"/>
<input type="button" Class="cancel" value="Cancel" OnClick="hideInput('addFactDiv');" />
<asp:Button ID="Submit_Fact" CssClass="submit" runat="server" CausesValidation="true" ValidationGroup="ValidateFact" Text="Submit" OnClick="Submit_Fact_Click"/>
</div>
EDIT
I had some commented out fields as well on the page causing the two errors I have mentioned in comments. When I removed those fields it started working fine. However I am not sure why.. Do commented out fields also get rendered on the page the same way as others?
I tried on my sample application and found below error,
WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive).
Later I found that we need to add below key in .config file, which fixed the issue. (I am not sure why!)
Ref: Link
My aspx code looks like below,
<form id="form1" runat="server">
<div>
<div id="addFactDiv" style="float: right">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
</div>
<p>
<asp:Button ID="Button1" runat="server" Text="Button" ValidationGroup="test" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="RequiredFieldValidator" ValidationGroup="test"></asp:RequiredFieldValidator>
</p>
</form>
Hope this might help!!

How can I access the textbox value

<asp:DataList id="ItemsList"
BorderColor="black"
CellPadding="5"
CellSpacing="5"
RepeatDirection="Vertical"
RepeatLayout="Table"
RepeatColumns="3"
runat="server">
<ItemTemplate>
<a href="#" data-inline="true" data-role="button"
data-icon="star" data-iconpos="right">
<input type="text" id="txtTry" style="width: 20%" runat="server"
value="" data-mini="true"
<%# DataBinder.Eval(Container.DataItem, "StringValue") %>
</a>
</ItemTemplate>
</asp:DataList>
how can I access the value of the text box of each button in the CS. How can I access it.This is not tough but I didn't use it yet.
You need to change HTML controls <input>
to the ASP.NET controls, for example:
<asp:TextBox ID="txtTry" runat="server"></asp:TextBox>
Then later in your .cs file you can change the value of the textbox:
...
txtTry.Text = "foo";
...
yes change the html to Asp.net text box. Then you can get via method mentioned by oleksii
Even with input html text try the below sample It should normally be done with
Request.Form["elementName"]
For example, if you have
<input type="text" name="try" /> then you can use Request.Form["try"] to access its value.

multiple submit buttons won't postback on aspx - only last button

On my aspx page I have two fieldsets, each wrapped with an <asp:Panel DefaultButton="..."> that have their own <input type="submit"> buttons. Here's an abbreviated version...
<div id="content">...</div>
<asp:Panel runat="server" id="formPanel1" DefaultButton="form1SubmitButton">
<fieldset>
<asp:TextBox runat="server" id="textbox1"/>
<asp:TextBox runat="server" id="textbox2"/>
<asp:Button runat="server" id="form1SubmitButton" OnClick="form1SubmitButton_OnClick"/>
</fieldset>
</asp:Panel>
<asp:Panel runat="server" id="formPanel2" DefaultButton="form2SubmitButton">
<fieldset>
<asp:TextBox runat="server" id="textbox3"/>
<asp:TextBox runat="server" id="textbox4"/>
<asp:Button runat="server" id="form2SubmitButton" OnClick="form2SubmitButton_OnClick"/>
</fieldset>
</asp:Panel>
Only the last submit button form2SubmitButton will postback, the other button does nothing when clicked. I have simplified the code above but I should mention that each form, Panel included, is kept in a separate user control that is registered on the aspx.
UPDATE: After some more research I've figured out that the submits are not working because of validators on the another fieldset on the master page. That fieldset is for signing into the site, so it is needed. Thoughts?
As PCasagrande mentioned, make sure your validation groups match the default button and all validators. Specially for your logging part.
Example:
<asp:Panel ID="pnlUpdateInfo" runat="server" DefaultButton="btnUpdateInfo">
<ASP:TEXTBOX id="txtZip" runat="server"></ASP:TEXTBOX>
<asp:RequiredFieldValidator id="reqvalZipSignUp" runat="server"
ControlToValidate="txtZip" ValidationGroup="btnUpdateInfo" />
<asp:Button ID="btnUpdateInfo" runat="server" ValidationGroup="btnUpdateInfo" />
</asp:Panel>
Turns out it has to do with HTML5 constraint validation. I figured this out because in chrome, from the console, I was getting the error An invalid form control with name='...' is not focusable. This led me to this post. I added the html5 attribute formnovalidate="formnovalidate" to the submit buttons and everything works just fine (*tested in chrome v20.0.1132.57, firefox v14.0.1, IE9 v9.0.8112).
So to recap, here's the answer...
<asp:Button runat="server" id="submit1" OnClick="submit1_OnClick" text="Submit" formnovalidate="formnovalidate"/>

Submit by pressing enter asp.net

I am wondering why this, submitting on pressing enter, is only working on ie and not on google chrome...
This is the code I use actually :
<div class="TxtBox">
<asp:Panel ID="lepanel" runat="server" DefaultButton="Connect">
<asp:TextBox ID="TxtUserLogin" runat="server" TabIndex="1" Text="login" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*"
Display="Static" ControlToValidate="TxtUserLogin"></asp:RequiredFieldValidator>
<asp:TextBox ID="UserPass" runat="server" TabIndex="2" Text="password" TextMode="Password" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*"
Display="Static" ControlToValidate="UserPass"></asp:RequiredFieldValidator>
<asp:LinkButton ID="Connect" runat="server" OnClick="Connect_Click" TabIndex="3">connect</asp:LinkButton>
</asp:Panel>
<asp:Label ID="MsgError" runat="server" />
<div class="ForgottenPass">
forgotten password ?
</div>
<div class="RememberMe">
<asp:CheckBox runat="server" ID="chkBoxRemember" />
stay signed in
</div>
</div>
A LinkButton renders as a HTML anchor tag.
HTML anchor tags do not submit HTML forms. Therefore when you click Enter, this is not actioning any submit button.
A Button renders as HTML <input type="submit" />
An ImageButton renders as HTML <input type="image" />
These elements will both action your form.
Therefore changing LinkButton to Button or ImageButton is the best solution.
Using a LinkButton is also bad for users who do not have javascript enabled.
This is a known issue, when you add as default a link button (actually a link) and not a real button then there is a case that is not trigger properly.
So if you change it to real button you make it work.

Asp.Net popup error message

Is there a way I can display an error message in a popup box? I'm using Asp.Net (C#), and on our webpage, if an order goes throug incorrectly we display an error message. Now, we would like to be able to do so using some sort of pop-up method (maybe Ajax?) - it should be able to take a string value to display the error message.
For a simple approach, you can have a script block that contains alert("your error message"). If you want the popup to be styled as the rest of your website then you could render your error message into a div element and use a jQuery dialog to display it as a modal dialog within your page.
I have used Ajax to accomplish this myself.
Using the ModalPopupExtender and setting the PopupControlID to an Asp Panel, I usually put this into a User Control so it can be easily used through a website.
However below is a snippet of the asp.net code
<div class="modalPopupAlign">
<asp:LinkButton ID="lnkConfirm" Style="display: none;" CausesValidation="false" runat="server" PostBackUrl="#">Confirm</asp:LinkButton>
<ajax:ModalPopupExtender ID="lnkConfirm_ModalPopupExtender" runat="server" TargetControlID="lnkConfirm" PopupControlID="pnlConfirmation" BackgroundCssClass="modalBackground" DropShadow="true" RepositionMode="None">
</ajax:ModalPopupExtender>
<div id="pnlConfirmation" class="modalPopup" style="display: none;">
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div class="modalPopupContainerAlign">
<div>
<asp:Image ID="imgIcon" CssClass="modalPopupImage" runat="server" />
<asp:Label ID="lblMessage" CssClass="modalPopupMessage" runat="server"></asp:Label>
<div class="modalPopupTextbox"><asp:TextBox ID="txtValue" Width="200px" MaxLength="100" Visible="false" runat="server"></asp:TextBox></div>
<asp:Button ID="btnAction" runat="server" CausesValidation="false" CssClass="defaultButton" Text="OK" />
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
It does take some time to get it working properly as I have had a few errors with the script manager, which I currently have setup in a master page.
Just might give you a direction to head for, and the CSS can help shape and colour the message box.
Although this is a complex way in some respect but has many uses.
You can do this with simple javascript like this...
alert("my error message");
Here is more info on using javascript

Categories

Resources