An Office service that supports add-ins to interact with objects in Office client applications.
Hi @VG,
Could you please help me by correcting or providing code to achieve this. Your prompt help is highly appreciated.
I think you may not understand what I meant earlier.
You can click on Complete (Handle method) and it checks if the element is test1 or test2 and then gets the value of the input after clicking the OK button.
Below is the complete code of my test, you can refer to it.
All Code
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src='https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.3.min.js'></script>
<script type="text/javascript" src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/js/bootstrap.min.js'></script>
<link rel="stylesheet" href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css'
media="screen" />
<script type="text/javascript">
function showAreaPopup() {
$("#idPopup").modal("show");
}
function captureAreaVal() {
var areaVal = document.getElementById('<%=TxtboxArea.ClientID%>').value;
if (areaVal && !isNaN(areaVal) && parseInt(areaVal) > 0) {
document.getElementById('<%=hiddenArea.ClientID %>').value = areaVal;
console.log("in captureareaval()", areaVal);
return true;
}
if (areaVal == null || areaVal == '') {
alert('Affected area is mandatory');
return false;
}
if (isNaN(areaVal)) {
alert('Please enter integer value for area affected');
return false;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<center>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="btnShowPopup" runat="server" Text="Show Popup" OnClick="Handle" CssClass="btn btn-info btn-lg" />
</center>
<!-- Modal -->
<div id="idPopup" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<label>Rating</label>
<asp:TextBox ID="TxtboxArea" class="form-control" runat="server"></asp:TextBox>
<asp:HiddenField ID="hiddenArea" runat="server" />
<asp:Label ID="lblMessage" Text="Please enter 100 only." runat="server" Visible="false" ForeColor="Red" />
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<asp:Button CssClass="actionButtons" ID="btnOK" runat="server" Text="OK" OnClientClick="captureAreaVal();" OnClick="Add" />
</div>
</div>
</div>
</div>
</form>
</body>
</html>
protected void Handle(object sender, EventArgs e)
{
if (TextBox1.Text == "test1")
{
ClientScript.RegisterStartupScript(this.GetType(), "ShowPopup", "showAreaPopup();", true); //at this point the popup table is not seen
}
}
protected void Add(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(TxtboxArea.Text))
{
int TestOneArea = Convert.ToInt32(TxtboxArea.Text);
//add data
//class.Details.Add(new Detail() { Name = "Test1Name", Value = TestOneArea});
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Class is saved');", true);
}
}
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread